Big big overhaul.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-03-26 12:14:54 +01:00
parent 8025303b57
commit 8c4d99d9e8
13 changed files with 268 additions and 161 deletions

View file

@ -1,76 +1,107 @@
{% extends 'profile_base.html' %} {% extends 'profile_base.html' %}
{% load i18n %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% block head_title %}{% trans "Account" %}{% endblock %} {% block head_title %}Account{% endblock %}
{% block profile_content %} {% block profile_content %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1>{% trans "E-mail Addresses" %}</h1> <div class="panel panel-default">
{% if user.emailaddress_set.all %} <div class="panel-heading">
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p> <h4>E-mail Addresses</h4>
</div>
<div class="panel-body">
<form action="{% url 'account_email' %}" class="email_list" method="post"> {% if user.emailaddress_set.all %}
{% csrf_token %} <p>The following e-mail addresses are associated with your account:</p>
<fieldset class="blockLabels"> <form action="{% url 'account_email' %}" class="email_list" method="post">
{% csrf_token %}
<fieldset class="blockLabels">
{% for emailaddress in user.emailaddress_set.all %} <table class="table">
<div class="ctrlHolder"> <thead>
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}"> <tr>
<th></th>
<th>Address</th>
<th>Status</th>
<th>Primary?</th>
</tr>
</thead>
<tbody>
<input {% for emailaddress in user.emailaddress_set.all %}
id="email_radio_{{forloop.counter}}" <tr class="ctrlHolder">
type="radio" <label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
name="email" <td>
value="{{emailaddress.email}}" <input
{% if emailaddress.primary or user.emailaddress_set.count == 1 %} id="email_radio_{{forloop.counter}}"
checked="checked" type="radio"
{%endif %} name="email"
/> value="{{emailaddress.email}}"
{% if emailaddress.primary or user.emailaddress_set.count == 1 %}
checked="checked"
{%endif %}
/>
</td>
<td>
{{ emailaddress.email }}
</td>
<td>
{% if emailaddress.verified %}
<span class="label label-success">Verified</span>
{% else %}
<span class="label label-danger">Unverified</span>
{% endif %}
</td>
<td>
{% if emailaddress.primary %}<span class="label label-primary">Primary</span>{% endif %}
</td>
</label>
</tr>
{% endfor %}
{{ emailaddress.email }} </tbody>
{% if emailaddress.verified %} </table>
<span class="badge">{% trans "Verified" %}</span>
{% else %}
<span class="badge">{% trans "Unverified" %}</span>
{% endif %}
{% if emailaddress.primary %}<span class="badge">{% trans "Primary" %}</span>{% endif %}
</label>
</div>
{% endfor %}
<div class="buttonHolder"> <div class="buttonHolder">
<button class="btn btn-black" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button> <button class="btn btn-success" type="submit" name="action_primary" >Make Primary</button>
<button class="btn btn-black" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button> <button class="btn btn-primary" type="submit" name="action_send" >Re-send Verification</button>
<button class="btn btn-black" type="submit" name="action_remove" >{% trans 'Remove' %}</button> <button class="btn btn-danger" type="submit" name="action_remove" >Remove</button>
</div> </div>
</fieldset> </fieldset>
</form> </form>
{% else %}
<p>
<strong>Warning:</strong> You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc.
</p>
{% endif %}
</div>
</div>
{% else %} <div class="panel panel-default">
<p><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p> <div class="panel-heading">
<h4>Add E-mail Address</h4>
</div>
<div class="panel-body">
<form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %}
{% bootstrap_form form %}
<button name="action_add" class="btn btn-success" type="submit">Add E-mail</button>
</form>
</div>
</div>
{% endif %}
<h2>{% trans "Add E-mail Address" %}</h2>
<form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %}
{% bootstrap_form form %}
<button name="action_add" class="btn btn-black" type="submit">{% trans "Add E-mail" %}</button>
</form>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
(function() { (function() {
var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}"; var message = "Do you really want to remove the selected e-mail address?";
var actions = document.getElementsByName('action_remove'); var actions = document.getElementsByName('action_remove');
if (actions.length) { if (actions.length) {
actions[0].addEventListener("click", function(e) { actions[0].addEventListener("click", function(e) {

View file

@ -16,7 +16,7 @@
<form class="login" method="POST"> <form class="login" method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
<button class="form-control btn btn-black" type="submit">{% trans "Login" %}</button> <button class="form-control btn btn-primary" type="submit">{% trans "Login" %}</button>
{% if redirect_field_value %} {% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" /> <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %} {% endif %}

View file

@ -10,7 +10,7 @@
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<button type="submit" <button type="submit"
class="btn btn-black form-control"> class="btn btn-danger form-control">
Logout Logout
</button> </button>
</form> </form>

View file

@ -7,13 +7,18 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1>Change password</h1> <div class="panel panel-default">
<div class="panel-heading">
<h4>Change Password</h4>
</div>
<div class="panel-body">
<form class="login" method="POST"> <form class="login" method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
<button class="form-control btn btn-black" type="submit">Save</button> <button class="form-control btn btn-primary" type="submit">Save</button>
</form> </form>
</div>
</div> </div>
</div> </div>

View file

@ -16,7 +16,7 @@
<form class="login" method="POST"> <form class="login" method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
<button class="form-control btn btn-black" type="submit">Send e-mail</button> <button class="form-control btn btn-primary" type="submit">Send e-mail</button>
</form> </form>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -13,7 +13,7 @@
<form class="login" method="POST"> <form class="login" method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
<button class="form-control btn btn-black" type="submit">{% trans "Sign Up" %}</button> <button class="form-control btn btn-success" type="submit">{% trans "Sign Up" %}</button>
</form> </form>
</div> </div>
</div> </div>

View file

@ -15,7 +15,7 @@
{% bootstrap_form form %} {% bootstrap_form form %}
<button type="submit" <button type="submit"
class="btn btn-black form-control"> class="btn btn-primary form-control">
{% trans 'Authenticate' %} {% trans 'Authenticate' %}
</button> </button>
</form> </form>

View file

@ -2,34 +2,49 @@
{% load account %} {% load account %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load i18n %}
{% block profile_content %} {% block profile_content %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1>
{% trans "Two-Factor Authentication Backup Tokens" %}
</h1>
<ul> <div class="panel panel-default">
{% for token in backup_tokens %} <div class="panel-heading">
<li>{{ token.token }}</li> <h4>Two-Factor Authentication Backup Tokens</h4>
{% empty %}
{% trans 'No tokens. Press the button below to generate some.' %}
{% endfor %}
</ul>
<form method="post">
{% csrf_token %}
<div class="buttonHolder">
<button class="btn btn-black" type="submit">
{% trans 'Generate backup tokens' %}
</button>
<a class="btn btn-warning" href="{% url 'two-factor-remove' %}">Disable Two-Factor</a>
</div> </div>
</form> <div class="panel-body">
{% if backup_tokens %}
<ul>
{% for token in backup_tokens %}
<li>{{ token.token }}</li>
{% endfor %}
</ul>
{% else %}
<p>No tokens. Press the button below to generate some.</p>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="buttonHolder">
<button class="btn btn-success" type="submit">
{% if backup_tokens %}
Generate new backup tokens
{% else %}
Generate new backup tokens
{% endif %}
</button>
</div>
</form>
</div>
</div>
<div class="panel panel-danger">
<div class="panel-heading">
<h4>Disable Two-Factor Authenticatoin</h4>
</div>
<div class="panel-body">
<a class="btn btn-danger" href="{% url 'two-factor-remove' %}">Disable Two-Factor</a>
</div>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -2,23 +2,26 @@
{% load account %} {% load account %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load i18n %}
{% block profile_content %} {% block profile_content %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1> <div class="panel panel-danger">
{% trans "Disable Two-Factor Authentication" %} <div class="panel-heading">
</h1> <h4>Disable Two-Factor Authentication</h4>
</div>
<div class="panel-body">
<p>Are you sure you want to disable two-factor authentication?</p>
<p>{% trans "Are you sure?" %}</p> <form method="post">
{% csrf_token %}
<form method="post"> <button class="btn btn-danger" type="submit">
{% csrf_token %} Yes, I'm sure
<button class="btn btn-danger" type="submit"> </button>
{% trans 'Disable Two-Factor' %} <a href="{% url 'two-factor-backup-tokens' %}" class="btn btn-success">No, I've changed my mind.</a>
</button> </form>
</form> </div>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -7,35 +7,38 @@
{% block profile_content %} {% block profile_content %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1> <div class="panel panel-default">
{% trans "Setup Two-Factor Authentication" %} <div class="panel-heading">
</h1> <h4>Setup Two-Factor Authentication</h4>
</div>
<div class="panel-body">
<h4>
{% trans 'Step 1' %}:
</h4>
<h4> <p>
{% trans 'Step 1' %}: {% trans 'Scan the QR code below with a token generator of your choice (for instance Google Authenticator).' %}
</h4> </p>
<p> <img src="{% url 'two-factor-qr-code' %}" />
{% trans 'Scan the QR code below with a token generator of your choice (for instance Google Authenticator).' %}
</p>
<img src="{% url 'two-factor-qr-code' %}" /> <h4>
{% trans 'Step 2' %}:
</h4>
<h4> <p>
{% trans 'Step 2' %}: {% trans 'Input a token generated by the app:' %}
</h4> </p>
<p> <form method="post">
{% trans 'Input a token generated by the app:' %} {% csrf_token %}
</p> {% bootstrap_form form %}
<button class="btn btn-success" type="submit">
<form method="post"> {% trans 'Verify' %}
{% csrf_token %} </button>
{% bootstrap_form form %} </form>
<button class="btn btn-black" type="submit"> </div>
{% trans 'Verify' %} </div>
</button>
</form>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -5,64 +5,78 @@
{% block content %} {% block content %}
<div class="page-header">
<h2>Your BornHack account</h2>
</div>
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li {% if view.active_menu == "profile" %}class="active"{% endif %}>
<a href="{% url 'profiles:detail' %}"> <li><b>Profile settings</b></li>
{% url 'profiles:detail' as profile_detail_url %}
<li {% if request.path == profile_detail_url %}class="active"{% endif %}>
<a href="{{ profile_detail_url }}">
Profile Profile
</a> </a>
</li> </li>
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> {% url 'account_change_password' as password_url %}
<a href="{% url 'account_change_password' %}"> <li {% if request.path == password_url %}class="active"{% endif %}>
<a href="{{ password_url }}">
Password Password
</a> </a>
</li> </li>
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> {% url 'account_email' as email_url %}
<a href="{% url 'two-factor-setup' %}"> <li {% if request.path == email_url %}class="active"{% endif %}>
Two-Factor settings <a href="{{ email_url }}">
</a>
</li>
<li {% if view.active_menu == "profile" %}class="active"{% endif %}>
<a href="{% url 'account_email' %}">
Manage emails Manage emails
</a> </a>
</li> </li>
{% url 'two-factor-setup' as two_factor_url %}
<li {% if "two_factor" in request.path %}class="active"{% endif %}>
<a href="{{ two_factor_url }}">
Two-Factor settings
</a>
</li>
{% if user.orders.exists %} {% if user.orders.exists %}
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> <li><b>Shop</b></li>
<li {% if view.active_menu == "orders" %}class="active"{% endif %}>
<a href="{% url 'shop:order_list' %}"> <a href="{% url 'shop:order_list' %}">
Orders Orders
</a> </a>
</li> </li>
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> <li {% if view.active_menu == "tickets" %}class="active"{% endif %}>
<a href="{% url 'tickets:shopticket_list' %}"> <a href="{% url 'tickets:shopticket_list' %}">
Tickets Tickets
</a> </a>
</li> </li>
{% if user.creditnotes.exists %} {% if user.creditnotes.exists %}
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> <li {% if view.active_menu == "credit_notes" %}class="active"{% endif %}>
<a href="{% url 'shop:creditnote_list' %}"> <a href="{% url 'shop:creditnote_list' %}">
Credit Notes Credit Notes
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% endif %} {% endif %}
<li {% if view.active_menu == "profile" %}class="active"{% endif %}> <li><b>Misc.</b></li>
<li {% if view.active_menu == "tokens" %}class="active"{% endif %}>
<a href="{% url 'tokens:tokenfind_list' %}"> <a href="{% url 'tokens:tokenfind_list' %}">
Secret Tokens Secret Tokens
</a> </a>
</li> </li>
<p><b>You are logged in as {{ request.user.email }}</b></p>
<hr /> <hr />
<p><b>You are logged in as {{ request.user.email }}</b></p>
</ul> </ul>
</div> </div>

View file

@ -1,26 +1,61 @@
{% extends 'profile_base.html' %} {% extends 'profile_base.html' %}
{% block profile_content %} {% block profile_content %}
<p class="lead">If you intend to join one or more teams you can use the profile to help the team responsible understand who you are and what you have to offer. Please also include availability if you are not joining us for the entire week.</p> {% if not profile.description %}
<p class="lead">Apart from Public Credit Name the information in your profile is only visible to team responsible and organisers.</p> <div class="alert alert-danger">
<h3>Your Profile</h3> <p class="lead">
<table class="table table-horisontal"> Attention!
<tr> </p>
<td><b>Name (not visible to the public)</b></td> <p>
<td>{{ profile.name|default:"N/A" }}</td> You have not written anything in your "description".
</tr> </p>
<tr> <p>
<td><b>Description (not visible to the public)</b></td> If you intend to join one or more teams you can use the profile to help the team responsible understand who you are and what you have to offer. Please also include availability if you are not joining us for the entire week.
<td>{{ profile.description|default:"N/A" }}</td> </p>
</tr> </div>
<tr> {% endif %}
<td><b>Public Credit Name (visible to the public, leave empty if you want no credits on this website)</b></td>
<td>{{ profile.public_credit_name|default:"N/A" }} {% if profile.public_credit_name %}({% if profile.public_credit_name_approved %}<span class="text-success">approved</span>{% else %}<span class="text-danger">pending approval</span>{% endif %}){% endif %}</td>
</tr>
<tr>
<td><b>NickServ username (visible to the public on IRC, used to handle team channel ACLs)</b></td> <div class="panel panel-default">
<td>{{ profile.nickserv_username|default:"N/A" }}</td> <div class="panel-heading">
</tr> <a href="{% url 'profiles:update' %}" class="btn btn-primary pull-right clearfix"><i class="fas fa-edit"></i> Edit Profile</a>
</table> <h4>Your information</h4>
<a href="{% url 'profiles:update' %}" class="btn btn-black"><i class="fas fa-edit"></i> Edit Profile</a> </div>
<div class="panel-body">
<table class="table table-striped">
<tr>
<td>
<b>Name</b><br />
<small>(not visible to the public)</small></td>
<td>{{ profile.name|default:"N/A" }}</td>
</tr>
<tr>
<td>
<b>Description</b><br />
<small>(not visible to the public)</small>
</td>
<td>{{ profile.description|default:"N/A" }}</td>
</tr>
<tr>
<td>
<b>Public Credit Name</b><br />
<small>(visible to the public, leave empty if you want no credits on this website)</small>
</td>
<td>
{{ profile.public_credit_name|default:"N/A" }} {% if profile.public_credit_name %}({% if profile.public_credit_name_approved %}<span class="text-success">approved</span>{% else %}<span class="text-danger">pending approval</span>{% endif %}){% endif %}</td>
</tr>
<tr>
<td>
<b>NickServ username</b><br />
<small>(visible to the public on IRC, used to handle team channel ACLs)</small>
</td>
<td>
{{ profile.nickserv_username|default:"N/A" }}
</td>
</tr>
</table>
</div>
</div>
{% endblock profile_content %} {% endblock profile_content %}

View file

@ -9,6 +9,7 @@ from . import models
class ProfileDetail(LoginRequiredMixin, DetailView): class ProfileDetail(LoginRequiredMixin, DetailView):
model = models.Profile model = models.Profile
template_name = 'profile_detail.html' template_name = 'profile_detail.html'
active_menu = 'profile'
def get_object(self, queryset=None): def get_object(self, queryset=None):
return models.Profile.objects.get(user=self.request.user) return models.Profile.objects.get(user=self.request.user)