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():
@security.authentication_required()
def profiles():
user = flask_login.current_user
services = []
profiles = []
for service in models.Service.query.all():
profiles = models.Profile.filter(service, user).all()
if profiles:
services.append((service, profiles))
return flask.render_template("account_profiles.html", services=services)
\ No newline at end of file
profiles.extend([
(service, profile) for profile in
models.Profile.filter(service, user).all()
])
return flask.render_template("account_profiles.html", profiles=profiles)
\ No newline at end of file
......@@ -5,14 +5,13 @@
{% block content %}
<div class="row">
{% for service, profiles in services %}
{% for profile in profiles %}
{% for service, profile in profiles %}
{% set service = profile.service %}
{% set status = profile.STATUSES[profile.status] %}
<div class="col-md-4 col-s-6 col-xs-12">
<div class="box box-widget widget-user-2">
<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-{{ status[0] }} text-black pull-right">{{ status[1] | capitalize }}</span>
<span class="btn btn-lg btn-flat bg-gray }} text-black pull-right">{{ status[1] | capitalize }}</span>
<h3 class="widget-header-username">{{ service.name }} / {{ profile.username }}</h3>
<h5 class="widget-header-desc">{{ profile.comment or "No profile description" }}&nbsp;</h5>
</div>
......@@ -20,21 +19,36 @@
<ul class="nav nav-stacked">
{% if profiles.__len__() == 0 or not service.single_profile %}
{% 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") %}
<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 %}
{% 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 %}
<li><a href="#"><i class="fa fa-share"></i>&nbsp;&nbsp;{% trans %}Share this profile (not implemented){% endtrans %}</a></li>
<li><a href="#"><i class="fa fa-trash"></i>&nbsp;&nbsp;{% trans %}Delete this profile (not implemented){% endtrans %}</a></li>
{% if profile.transition %}
{% 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>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
{% 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