Skip to content

Commit

Permalink
feat: Allow for linking rooms to a movie
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jun 30, 2024
1 parent 4c34402 commit 197083a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions templates/movie_action.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<br>
<br>
{{ form.category.label(class_="label") }} {{ form.category }}
<br>
<br>
{{ form.room.label(class_="label") }} {{ form.room }}
</p>
<br>
<p>{{ form.upload(class_="button is-success") }}</p>
Expand Down
1 change: 1 addition & 0 deletions theunderground/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MovieUploadForm(FlaskForm):
)
# Choices for the select field are only evaluated once, so we must set it when necessary.
category = SelectField("Movie category", validators=[DataRequired()])
room = SelectField("Room", validators=[DataRequired()])
upload = SubmitField("Add Movie")


Expand Down
12 changes: 11 additions & 1 deletion theunderground/mobiclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from time import gmtime, strftime

from room import s3
from models import Categories, PayCategories
from models import Categories, PayCategories, Rooms
from theunderground.encodemii import (
movie_thumbnail_encode,
pay_movie_thumbnail_encode,
Expand Down Expand Up @@ -125,6 +125,16 @@ def get_category_list():
return choice_categories


def get_room_list():
db_rooms = Rooms.query.all()

choice_rooms = []
for _, room in enumerate(db_rooms):
choice_rooms.append([room.room_id, room.news])

return choice_rooms


def get_pay_category_list():
db_categories = PayCategories.query.all()

Expand Down
6 changes: 5 additions & 1 deletion theunderground/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
delete_movie_data,
get_movie_path,
get_ds_movie_path,
get_room_list,
)
from theunderground.forms import MovieUploadForm
from theunderground.operations import manage_delete_item
Expand Down Expand Up @@ -55,6 +56,7 @@ def list_movies(category):
def add_movie():
form = MovieUploadForm()
form.category.choices = get_category_list()
form.room.choices = get_room_list()
form.movie.validators = [FileRequired()]
form.thumbnail.validators = [FileRequired()]

Expand All @@ -79,7 +81,7 @@ def add_movie():
length=length,
aspect=True,
genre=form.genre.data,
sp_page_id=0,
sp_page_id=form.room.data,
staff=False,
)

Expand Down Expand Up @@ -123,6 +125,7 @@ def add_movie():
def edit_movie(movie_id):
form = MovieUploadForm()
form.category.choices = get_category_list()
form.room.choices = get_room_list()
form.upload.label.text = "Edit"

movie = Movies.query.filter_by(movie_id=movie_id).first()
Expand Down Expand Up @@ -162,6 +165,7 @@ def edit_movie(movie_id):
movie.title = form.title.data
movie.genre = form.genre.data
movie.category_id = form.category.data
movie.sp_page_id = form.room.data
db.session.commit()

if s3:
Expand Down

0 comments on commit 197083a

Please sign in to comment.