-
-
Save abhisuri97/3713785a46b90cacfa03751f5ecf8d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'layouts/base.html' %} | |
{% import 'macros/form_macros.html' as f %} | |
{% set deletion_endpoint = 'club.delete_club_request' %} | |
{% set endpoints = [ | |
('club.club_info', 'Club information', 'false'), | |
('club.change_club_details', 'Change club details', 'true'), | |
(deletion_endpoint, 'Delete club', 'true') | |
] %} | |
{% macro navigation(items) %} | |
<div class="ui vertical fluid secondary menu"> | |
{% for route, name, is_admin in items %} | |
{% set disp = True %} | |
{% if is_admin == 'true' and current_user.is_admin() == False %} | |
{% set disp = False %} | |
{% endif %} | |
{% if disp == True %} | |
{% set href = url_for(route, club_id=club.id) %} | |
<a class="item {% if request.endpoint == route %}active{% endif %}" href="{{ href }}"> | |
{{ name }} | |
</a> | |
{% endif %} | |
{% endfor %} | |
</div> | |
{% endmacro %} | |
{% macro club_info(club) %} | |
<table class="ui compact definition table"> | |
<tr><td>Name</td><td>{{ club.name }}</td></tr> | |
<tr><td>Categories</td><td>{% for c in club.categories %} {{ c.category_name }} {% endfor %}</td></tr> | |
<div style="overflow-x: scroll;"> | |
<table class="ui searchable sortable unstackable selectable celled table"> | |
<thead> | |
<tr> | |
<th>Answer</th> | |
<th>Rating</th> | |
<th>Question</th> | |
{% if current_user.is_admin() %}<th>Delete?</th>{% endif %} | |
</tr> | |
</thead> | |
<tbody> | |
{% for a in club.answers | sort(attribute='id') %} | |
<td>{{ a.answer }}</td> | |
<td>{{ a.rating }}</td> | |
<td>{{ a.question.content }}</td> | |
{% if current_user.is_admin() %} | |
<td onclick="window.location.href = '{{ url_for('question.delete_answer', answer_id=a.id) }}';"> | |
<a>Delete Answer</a></td> {% endif %} | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
</div> | |
</div> | |
</table> | |
{% endmacro %} | |
{% block content %} | |
<div class="ui stackable centered grid container"> | |
<div class="twelve wide column"> | |
{% if current_user.is_admin() %} | |
<a class="ui basic compact button" href="{{ url_for('club.clubs') }}"> | |
<i class="caret left icon"></i> | |
Back to all clubs | |
</a> | |
{% else %} | |
<a class="ui basic compact button" href="{{ url_for('main.index') }}"> | |
<i class="caret left icon"></i> | |
Back to all club ratings | |
</a> | |
{% endif %} | |
<h2 class="ui header"> | |
{{ club.name }} | |
<div class="sub header">View {% if current_user.is_admin() %}and manage{% endif %} this club.</div> | |
</h2> | |
<h3 style="text-align: center"> | |
<a href="{{ url_for('main.submit_review', club_id=club.id ) }}">Add a review for this club</a> | |
</h3> | |
</div> | |
<div class="stretched divided very relaxed row"> | |
<div class="four wide column"> | |
{{ navigation(endpoints) }} | |
</div> | |
<div class="eight wide column"> | |
{% if request.endpoint == deletion_endpoint %} | |
<h3 class="ui red block header"> | |
<i class="warning circle icon"></i> | |
<div class="content"> | |
This action is permanent | |
<div class="sub header"> | |
Deleting a club is not a reversible change. Any information associated | |
with this club will be removed, and cannot be recovered. | |
</div> | |
</div> | |
</h3> | |
<div class="ui form"> | |
<div class="inline field"> | |
<div class="ui deletion checkbox"> | |
<input type="checkbox" tabindex="0" class="hidden"> | |
<label>I understand that this action cannot be undone.</label> | |
</div> | |
</div> | |
<a class="ui disabled negative deletion button"> | |
Delete this club | |
</a> | |
</div> | |
</div> | |
{% elif form %} | |
{{ f.render_form(form) }} | |
{% else %} | |
{{ club_info(club) }} | |
{% endif %} | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$('.deletion.checkbox').checkbox({ | |
onChecked: function() { | |
$('.deletion.button').removeClass('disabled') | |
.attr('href', '{{ url_for('club.delete_club', club_id=club.id) }}'); | |
}, | |
onUnchecked: function() { | |
$('.deletion.button').addClass('disabled').removeAttr('href'); | |
} | |
}); | |
</script> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment