MediaDash/templates/requests/index.html

117 lines
4.8 KiB
HTML
Raw Permalink Normal View History

2021-12-13 18:11:43 +00:00
{% extends "base.html" %}
{% from 'utils.html' import custom_render_form_row,make_tabs %}
{% from 'bootstrap/utils.html' import render_icon %}
{% from 'bootstrap/form.html' import render_form, render_field, render_form_row %}
{% macro search_tab() %}
<form method="post" enctype="multipart/form-data">
{{ form.csrf_token() }}
{{ custom_render_form_row([form.query],render_args={'form_type':'horizontal','horizontal_columns':('lg',1,6)}) }}
{{ custom_render_form_row([form.search_type],render_args={'form_type':'horizontal','horizontal_columns':('lg',1,6)}) }}
{{ custom_render_form_row([form.search]) }}
</form>
{% if results %}
<form method="post">
{{ form.csrf_token() }}
{% if search_type %}
<input type="hidden" name="search_type" value="{{search_type}}">
{% endif %}
<table class="table table-sm table-bordered mt-3">
<tr>
<th>Title</th>
<th>In Cinemas</th>
<th>Digital Release</th>
</tr>
{% for result in results %}
{% if result.tvdbId %}
{% set link="https://www.thetvdb.com/?tab=series&id=%s"|format(result.tvdbId) %}
{% elif result.imdbId %}
{% set link="https://www.imdb.com/title/%s"|format(result.imdbId) %}
{% endif %}
{% if result.path %}
{% set style="background-color: darkgreen !important;" %}
{% else %}
{% set style="" %}
{% endif %}
<tr style="{{style}}">
<td>
{% if result.path %}
<input type="checkbox" disabled>
{% else %}
<input type="checkbox" name="selected[]" value="{{result|tojson|base64}}">
{% endif %}
<a href="{{link}}">{{result.title}}</a> ({{result.year}})
</td>
<td>
{% if result.inCinemas %}
{{result.inCinemas|fromiso}}
{% else %}
None
{% endif %}
</td>
<td>
{% if result.digitalRelease %}
{{result.digitalRelease|fromiso}}
{% else %}
None
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<button class="btn btn-success" type="submit">Submit Request</button>
</form>
{% endif %}
{% endmacro %}
{% macro request_queue() %}
<form method="post">
{{ form.csrf_token() }}
<table class="table table-sm table-bordered mt-3">
<tr>
<th>Title</th>
<th>Requested at</th>
{% if current_user.is_admin %}
<th>Requested by</th>
{% endif %}
</tr>
{% for request in requests %}
{% set data = (request.data|fromjson) %}
{% if request.approved==True %}
<tr class="bg-success">
{% elif request.approved==False %}
<tr class="bg-danger">
{% else %}
<tr class="">
{% endif %}
<td>
{% if current_user.is_admin and request.approved!=True %}
<input type="checkbox" name="selected[]" value="{{request.item_id}}">
{% endif %}
<a href="{{url_for('requests.details',request_id=request.id)}}" style="color: #eee; text-decoration: underline;">{{data.title}}</a> ({{data.year}})
</td>
<td>{{request.added_date}}</td>
{% if current_user.is_admin %}
<td>{{request.users|join(", ",attribute="user_name")}}</td>
{% endif %}
</tr>
{% endfor %}
</table>
{% if current_user.is_admin %}
<button name="approve" value="approve" class="btn btn-success" type="submit">Approve</button>
<button name="decline" value="decline" class="btn btn-danger" type="submit">Decline</button>
{% endif %}
</form>
{% endmacro %}
{% block app_content %}
<h1>Requests</h1>
{% set requests_tabs = [
('Queue',request_queue()),
('Search',search_tab()),
] %}
{{ make_tabs(requests_tabs) }}
{% endblock %}