Skip to content
Snippets Groups Projects
Commit b85aa30b authored by kaiyou's avatar kaiyou
Browse files

Refactor the profile list and add a deletion link

parent 16cf7f50
No related branches found
No related tags found
No related merge requests found
...@@ -15,9 +15,10 @@ def home(): ...@@ -15,9 +15,10 @@ def home():
@security.authentication_required() @security.authentication_required()
def profiles(): def profiles():
user = flask_login.current_user user = flask_login.current_user
services = [] profiles = []
for service in models.Service.query.all(): for service in models.Service.query.all():
profiles = models.Profile.filter(service, user).all() profiles.extend([
if profiles: (service, profile) for profile in
services.append((service, profiles)) models.Profile.filter(service, user).all()
return flask.render_template("account_profiles.html", services=services) ])
\ No newline at end of file return flask.render_template("account_profiles.html", profiles=profiles)
\ No newline at end of file
...@@ -5,14 +5,13 @@ ...@@ -5,14 +5,13 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
{% for service, profiles in services %} {% for service, profile in profiles %}
{% for profile in profiles %}
{% set service = profile.service %} {% set service = profile.service %}
{% set status = profile.STATUSES[profile.status] %}
<div class="col-md-4 col-s-6 col-xs-12"> <div class="col-md-4 col-s-6 col-xs-12">
<div class="box box-widget widget-user-2"> <div class="box box-widget widget-user-2">
<div class="widget-user-header bg-{{ macros.colors[loop.index0 % 7] }}"> <div class="widget-user-header bg-{{ macros.colors[loop.index0 % 7] }}">
{% set status = profile.STATUSES[profile.status] %} <span class="btn btn-lg btn-flat bg-gray }} text-black pull-right">{{ status[1] | capitalize }}</span>
<span class="btn btn-lg btn-flat bg-{{ status[0] }} text-black pull-right">{{ status[1] | capitalize }}</span>
<h3 class="widget-header-username">{{ service.name }} / {{ profile.username }}</h3> <h3 class="widget-header-username">{{ service.name }} / {{ profile.username }}</h3>
<h5 class="widget-header-desc">{{ profile.comment or "No profile description" }}&nbsp;</h5> <h5 class="widget-header-desc">{{ profile.comment or "No profile description" }}&nbsp;</h5>
</div> </div>
...@@ -20,21 +19,36 @@ ...@@ -20,21 +19,36 @@
<ul class="nav nav-stacked"> <ul class="nav nav-stacked">
{% if profiles.__len__() == 0 or not service.single_profile %} {% if profiles.__len__() == 0 or not service.single_profile %}
{% if service.policy in ("open", "burst") and profiles.__len__() < service.max_profiles %} {% if service.policy in ("open", "burst") and profiles.__len__() < service.max_profiles %}
<li><a href="{{ utils.url_for("profile.create", service_uuid=service.uuid) }}"><i class="fa fa-user-plus"></i>&nbsp;&nbsp;{% trans %}Create another profile{% endtrans %}</a></li> <li>
<a href="{{ utils.url_for("profile.create", service_uuid=service.uuid) }}">
<i class="fa fa-user-plus"></i>&nbsp;
{% trans %}Create another profile{% endtrans %}
</a>
</li>
{% elif service.policy in ("managed", "burst") %} {% elif service.policy in ("managed", "burst") %}
<li><a href="{{ utils.url_for("profile.create", service_uuid=service.uuid) }}"><i class="fa fa-user-plus"></i>&nbsp;&nbsp;{% trans %}Request another profile{% endtrans %}</a></li> <li><a href="{{ utils.url_for("profile.create", service_uuid=service.uuid) }}"><i class="fa fa-user-plus"></i>&nbsp;&nbsp;{% trans %}Request another profile{% endtrans %}</a></li>
{% endif %} {% endif %}
{% if service.policy not in ("locked",) %} {% if service.policy not in ("locked",) %}
<li><a href="{{ utils.url_for("profile.claim", service_uuid=service.uuid) }}"><i class="fa fa-user-plus"></i>&nbsp;&nbsp;{% trans %}Claim a profile{% endtrans %}</a></li> <li><a href="{{ utils.url_for("profile.claim", service_uuid=service.uuid) }}"><i class="fa fa-user-plus"></i>&nbsp;&nbsp;{% trans %}Claim another profile{% endtrans %}</a></li>
{% endif %} {% endif %}
{% endif %} {% endif %}
<li><a href="#"><i class="fa fa-share"></i>&nbsp;&nbsp;{% trans %}Share this profile (not implemented){% endtrans %}</a></li> {% if profile.transition %}
<li><a href="#"><i class="fa fa-trash"></i>&nbsp;&nbsp;{% trans %}Delete this profile (not implemented){% endtrans %}</a></li> {% set color, status = profile.STATUSES[profile.TRANSITIONS[profile.transition][1]] %}
{% set when = profile.transition_delta(True) %}
<li>
<a href="#">
<i class="fa fa-clock-o"></i>&nbsp;
{% trans status, when %}Profile will be {{ status }} in {{ when }}{% endtrans %}
</a>
</li>
{% endif %}
{% if "delete" in profile.transitions() %}
<li><a href="{{ url_for("profile.start_transition", profile_uuid=profile.uuid, transition="delete") }}"><i class="fa fa-trash"></i>&nbsp;&nbsp;{% trans %}Delete this profile{% endtrans %}</a></li>
{% endif %}
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
{% endfor %}
</div> </div>
{% endblock %} {% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment