Commit 8f012ba1 authored by Manuel Cortez's avatar Manuel Cortez

Added season and episode editing

parent d827ddfa
......@@ -268,4 +268,66 @@ def edit_show():
if form.process().accepted:
response.flash = ("Show edited successfully")
return redirect(URL("administration", "manage_shows"))
return dict(share=False, form=form)
@auth.requires_login()
def manage_seasons():
if auth.user_id != 1: return redirect(URL("default", "index"))
show_id = request.vars.id
if show_id == None:
return redirect(URL("default", "index"))
show = db(db.tv_show.id == show_id).select().first()
if show == None:
return redirect(URL("default", "index"))
seasons = db(db.tv_season.show == show).select()
response.title = T("Manage seasons for {0}").format(show.show_title)
return dict(share=False, seasons=seasons)
@auth.requires_login()
def edit_season():
if auth.user_id != 1: return redirect(URL("default", "index"))
season_id = request.vars.id
if type(season_id) == list:
season_id = season_id[0]
if season_id == None:
return redirect(URL("default", "index"))
season = db(db.tv_season.id == season_id).select().first()
if season == None:
return redirect(URL("default", "index"))
response.title = T("Edit {0}, {1}").format(season.show.show_title, season.name)
form = SQLFORM(db.tv_season, season, deletable=True)
if form.process().accepted:
response.flash = ("Season edited successfully")
return redirect(URL("administration", "manage_seasons", vars=dict(id=show.id)))
return dict(share=False, form=form)
@auth.requires_login()
def manage_episodes():
if auth.user_id != 1: return redirect(URL("default", "index"))
season_id = request.vars.id
if season_id == None:
return redirect(URL("default", "index"))
season = db(db.tv_season.id == season_id).select().first()
if season == None:
return redirect(URL("default", "index"))
episodes = db(db.tv_episode.season_number == season).select()
response.title = T("Manage episodes for {0}, {1}").format(season.show.show_title, season.name)
return dict(share=False, episodes=episodes)
@auth.requires_login()
def edit_episode():
if auth.user_id != 1: return redirect(URL("default", "index"))
episode_id = request.vars.id
if type(episode_id) == list:
episode_id = episode_id[0]
if episode_id == None:
return redirect(URL("default", "index"))
episode = db(db.tv_episode.id == episode_id).select().first()
if episode == None:
return redirect(URL("default", "index"))
response.title = T("Edit {0}, {1}").format(episode.show.show_title, episode.name)
form = SQLFORM(db.tv_episode, episode, deletable=True)
if form.process().accepted:
response.flash = ("Episode edited successfully")
return redirect(URL("administration", "manage_episodes", vars=dict(id=episode.season_number.id)))
return dict(share=False, form=form)
\ No newline at end of file
......@@ -27,7 +27,7 @@ db.define_table("tv_show",
# tv_show is a table reference to an item present in the tv_show table.
# Here we still save just general info, no episodes nor media files are stored here.
db.define_table("tv_season",
Field("show", "reference tv_show", required=True),
Field("show", "reference tv_show", required=True, readable=False, writable=False),
Field("name", "string", required=True),
Field("season_number", "integer"),
Field("first_aired", "date"),
......@@ -56,21 +56,21 @@ db.define_table("movie",
Field("overview", "text"),
Field("genre", "string"),
Field("image", "string"),
Field("file", "reference media", readable=False, writeable=False),
Field("file", "reference media", readable=False, writable=False),
Field("language", "reference languages", required=True))
db.define_table("tv_episode",
Field("show", "reference tv_show", required=True),
Field("show", "reference tv_show", required=True, readable=False, writable=False),
Field("name", "string", required=True),
Field("episode_number", "integer"),
Field("season_number", "reference tv_season"),
Field("season_number", "reference tv_season", required=True, readable=False, writable=False),
Field("first_aired", "date"),
Field("movie_db_id", "string"),
Field("rating", "double"),
Field("rating_count", "integer"),
Field("overview", "text"),
Field("image", "string"),
Field("file", "reference media", readable=False, writeable=False))
Field("file", "reference media", readable=False, writable=False))
db.define_table("saved_file",
Field("file", "reference media"),
......
{{extend 'layout.html'}}
{{block header}}
<header class="container-fluid background">
<div class="jumbotron text-center">
</div>
</header>
{{end}}
{{=form}}
\ No newline at end of file
{{extend 'layout.html'}}
{{block header}}
<header class="container-fluid background">
<div class="jumbotron text-center">
</div>
</header>
{{end}}
{{=form}}
\ No newline at end of file
{{extend 'layout.html'}}
{{block header}}
<header class="container-fluid background">
<div class="jumbotron text-center">
</div>
</header>
{{end}}
<table><caption>{{=T("Episode list")}}</caption><thead><tr><th>{{=T("Episode")}}</th><th>{{=T("Language")}}</th><th>{{=T("Actions")}}</th></tr></thead>
{{for i in range(0, len(episodes)):}}
<tr><td>{{="{0}. {1}".format(episodes[i].episode_number, episodes[i].name)}}</td><td>{{=episodes[i].show.language.locale_name}}</td><td>{{=A(T("Edit"), _href=URL("administration", "edit_episode", vars=dict(id=episodes[i].id)))}}</td></tr>
{{pass}}
</table>
\ No newline at end of file
{{extend 'layout.html'}}
{{block header}}
<header class="container-fluid background">
<div class="jumbotron text-center">
</div>
</header>
{{end}}
<table><caption>{{=T("Season list")}}</caption><thead><tr><th>{{=T("Season")}}</th><th>{{=T("Language")}}</th><th>{{=T("Actions")}}</th></tr></thead>
{{for i in range(0, len(seasons)):}}
<tr><td>{{=seasons[i].name}}</td><td>{{=seasons[i].show.language.locale_name}}</td><td>{{=A(T("Edit"), _href=URL("administration", "edit_season", vars=dict(id=seasons[i].id)))}} | {{=A(T("Manage episodes"), _href=URL("administration", "manage_episodes", vars=dict(id=seasons[i].id)))}}</td></tr>
{{pass}}
</table>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment