Commit 0eb8fd5b authored by alexandre's avatar alexandre

Merge branch 'user-fun'

parents 2d04d5fd 36c46d90
......@@ -27,6 +27,9 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django_filters',
'compressor',
......@@ -106,8 +109,14 @@ STATICFILES_FINDERS = (
)
# Django registration
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
# cf <https://stackoverflow.com/questions/30871033/django-rest-framework-remove-csrf>
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
# 'rest_framework.authentication.TokenAuthentication',
'playground.authentication.CsrfExemptSessionAuthentication',
'rest_framework.authentication.BasicAuthentication'
)
}
# Django Compressor setup
COMPRESS_PRECOMPILERS = (
......
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Activation Failure" %}{% endblock %}
{% block content %}
<p>{% trans "Account activation failed." %}</p>
{% endblock %}
{% comment %}
**registration/activate.html**
Used if account activation fails. With the default setup, has the following context:
``activation_key``
The activation key used during the activation attempt.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Account Activated" %}{% endblock %}
{% block content %}
<p>
{% trans "Your account is now activated." %}
{% if not user.is_authenticated %}
{% trans "You can log in." %}
{% endif %}
</p>
{% endblock %}
{% comment %}
**registration/activation_complete.html**
Used after successful account activation. This template has no context
variables of its own, and should simply inform the user that their
account is now active.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Account Activated" %}{% endblock %}
{% block content %}
<p>
{% trans "Your account is now activated." %}
{% if not user.is_authenticated %}
{% trans "Once a site administrator activates your account you can login." %}
{% endif %}
</p>
{% endblock %}
{% comment %}
**registration/activation_complete.html**
Used after successful account activation. This template has no context
variables of its own, and should simply inform the user that their
account is now active.
{% endcomment %}
{% load i18n %}
<!doctype html>
<html lang="en">
<head>
<title>{{ site.name }} {% trans "registration" %}</title>
</head>
<body>
<p>
{% blocktrans with site_name=site.name %}
You (or someone pretending to be you) have asked to register an account at
{{ site_name }}. If this wasn't you, please ignore this email
and your address will be removed from our records.
{% endblocktrans %}
</p>
<p>
{% blocktrans %}
To activate this account, please click the following link within the next
{{ expiration_days }} days:
{% endblocktrans %}
</p>
<p>
<a href="http://{{site.domain}}{% url 'registration_activate' activation_key %}">
{{site.domain}}{% url 'registration_activate' activation_key %}
</a>
</p>
<p>
{% blocktrans with site_name=site.name %}
Sincerely,
{{ site_name }} Management
{% endblocktrans %}
</p>
</body>
</html>
{% comment %}
**registration/activation_email.html**
Used to generate the html body of the activation email. Should display a
link the user can click to activate the account. This template has the
following context:
``activation_key``
The activation key for the new account.
``expiration_days``
The number of days remaining during which the account may be
activated.
``site``
An object representing the site on which the user registered;
depending on whether ``django.contrib.sites`` is installed, this
may be an instance of either ``django.contrib.sites.models.Site``
(if the sites application is installed) or
``django.contrib.sites.requests.RequestSite`` (if not). Consult `the
documentation for the Django sites framework
<http://docs.djangoproject.com/en/dev/ref/contrib/sites/>`_ for
details regarding these objects' interfaces.
``user``
The new user account
``request``
``HttpRequest`` instance for better flexibility.
For example it can be used to compute absolute register URL:
{{ request.scheme }}://{{ request.get_host }}{% url 'registration_activate' activation_key %}
{% endcomment %}
{% load i18n %}
{% blocktrans with site_name=site.name %}
You (or someone pretending to be you) have asked to register an account at
{{ site_name }}. If this wasn't you, please ignore this email
and your address will be removed from our records.
{% endblocktrans %}
{% blocktrans %}
To activate this account, please click the following link within the next
{{ expiration_days }} days:
{% endblocktrans %}
http://{{site.domain}}{% url 'registration_activate' activation_key %}
{% blocktrans with site_name=site.name %}
Sincerely,
{{ site_name }} Management
{% endblocktrans %}
{% comment %}
**registration/activation_email.txt**
Used to generate the text body of the activation email. Should display a
link the user can click to activate the account. This template has the
following context:
``activation_key``
The activation key for the new account.
``expiration_days``
The number of days remaining during which the account may be
activated.
``site``
An object representing the site on which the user registered;
depending on whether ``django.contrib.sites`` is installed, this
may be an instance of either ``django.contrib.sites.models.Site``
(if the sites application is installed) or
``django.contrib.sites.requests.RequestSite`` (if not). Consult `the
documentation for the Django sites framework
<http://docs.djangoproject.com/en/dev/ref/contrib/sites/>`_ for
details regarding these objects' interfaces.
``user``
The new user account
``request``
``HttpRequest`` instance for better flexibility.
For example it can be used to compute absolute register URL:
{{ request.scheme }}://{{ request.get_host }}{% url 'registration_activate' activation_key %}
{% endcomment %}
{% load i18n %}{% trans "Account activation on" %} {{ site.name }}
{% comment %}
**registration/activation_email_subject.txt**
Used to generate the subject line of the activation email. Because the
subject line of an email must be a single line of text, any output
from this template will be forcibly condensed to a single line before
being used. This template has the following context:
``activation_key``
The activation key for the new account.
``expiration_days``
The number of days remaining during which the account may be
activated.
``site``
An object representing the site on which the user registered;
depending on whether ``django.contrib.sites`` is installed, this
may be an instance of either ``django.contrib.sites.models.Site``
(if the sites application is installed) or
``django.contrib.sites.requests.RequestSite`` (if not). Consult `the
documentation for the Django sites framework
<http://docs.djangoproject.com/en/dev/ref/contrib/sites/>`_ for
details regarding these objects' interfaces.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Approval Failure" %}{% endblock %}
{% block content %}
<p>{% trans "Account Approval failed." %}</p>
{% endblock %}
{% comment %}
**registration/admin_approve.html**
Used if account activation fails. With the default setup, has the following context:
``activation_key``
The activation key used during the activation attempt.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Account Approved" %}{% endblock %}
{% block content %}
<p>
{% trans "The user's account is now approved." %}
</p>
{% endblock %}
{% comment %}
**registration/admin_approve_complete.html**
Used after admin successfully approves a user's account. This template has no context
variables of its own, and should simply inform the admin that the user's
account is now active.
{% endcomment %}
{% load i18n %}
<!doctype html>
<html lang="en">
<head>
<title>{{ site.name }} {% trans "admin approval" %}</title>
</head>
<body>
<p>
{% blocktrans %}
Your account is now approved. You can
{% endblocktrans %}
<a href="http://{{site.domain}}{% url 'login' %}">{% trans "log in." %}</a>
</p>
</body>
</html>
{% comment %}
**registration/admin_approve_complete_email.html**
Used after successful account activation. This template has no context
variables of its own, and should simply inform the user that their
account is now active.
{% endcomment %}
{% load i18n %}
{% blocktrans %}
Your account is now approved. You can log in using the following link
{% endblocktrans %}
http://{{site.domain}}{% url 'login' %}
{% comment %}
**registration/admin_approve_complete_email.txt**
Used after successful account activation. This template has no context
variables of its own, and should simply inform the user that their
account is now active.
{% endcomment %}
{% load i18n %}{% trans "Account activation on" %} {{ site.name }}
{% comment %}
**registration/admin_approve_complete_email_subject.txt**
Used to generate the subject line of the admin approval complete email. Because
the subject line of an email must be a single line of text, any output
from this template will be forcibly condensed to a single line before
being used. This template has the following context:
``site``
An object representing the site on which the user registered;
depending on whether ``django.contrib.sites`` is installed, this
may be an instance of either ``django.contrib.sites.models.Site``
(if the sites application is installed) or
``django.contrib.sites.requests.RequestSite`` (if not). Consult `the
documentation for the Django sites framework
<http://docs.djangoproject.com/en/dev/ref/contrib/sites/>`_ for
details regarding these objects' interfaces.
{% endcomment %}
{% load i18n %}
<!doctype html>
<html lang="en">
<head>
<title>{{ site.name }} {% trans "registration" %}</title>
</head>
<body>
<p>
{% blocktrans with site_name=site.name %}
The following user ({{ user }}) has asked to register an account at
{{ site_name }}.
{% endblocktrans %}
</p>
<p>
{% blocktrans %}
To approve this, please
{% endblocktrans %}
<a href="http://{{site.domain}}{% url 'registration_admin_approve' profile_id %}"> {% trans "click here" %}</a>.
</p>
<p>
{% blocktrans with site_name=site.name %}
Sincerely,
{{ site_name }} Management
{% endblocktrans %}
</p>
</body>
</html>
\ No newline at end of file
{% load i18n %}
{% blocktrans with site_name=site.name %}
The following user ({{ user }}) has asked to register an account at
{{ site_name }}.
{% endblocktrans %}
{% blocktrans %}
To approve this, please click the following link.
{% endblocktrans %}
http://{{site.domain}}{% url 'registration_admin_approve' profile_id %}
\ No newline at end of file
{% load i18n %}{% trans "Account approval on" %} {{ site.name }}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Log in" %}{% endblock %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Log in' %}" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
<p>{% trans "Forgot your password?" %} <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>.</p>
<p>{% trans "Not a member?" %} <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>.</p>
{% endblock %}
{% comment %}
**registration/login.html**
It's your responsibility to provide the login form in a template called
registration/login.html by default. This template gets passed four
template context variables:
``form``
A Form object representing the login form. See the forms
documentation for more on Form objects.
``next``
The URL to redirect to after successful login. This may contain a
query string, too.
``site``
The current Site, according to the SITE_ID setting. If you don't
have the site framework installed, this will be set to an instance
of RequestSite, which derives the site name and domain from the
current HttpRequest.
``site_name``
An alias for site.name. If you don't have the site framework
installed, this will be set to the value of
request.META['SERVER_NAME']. For more on sites, see The
"sites" framework.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Logged out" %}{% endblock %}
{% block content %}
<p>{% trans "Successfully logged out" %}.</p>
{% endblock %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Password changed" %}{% endblock %}
{% block content %}
<p>{% trans "Password successfully changed!" %}</p>
{% endblock %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Change password" %}{% endblock %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Change password' %}" />
</form>
{% endblock %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Password reset complete" %}{% endblock %}
{% block content %}
<p>
{% trans "Your password has been reset!" %}
{% blocktrans %}You may now <a href="{{ login_url }}">log in</a>{% endblocktrans %}.
</p>
{% endblock %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Confirm password reset" %}{% endblock %}
{% block content %}
<p>{% trans "Enter your new password below to reset your password:" %}</p>
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Set password' %}" />
</form>
{% endblock %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Password reset" %}{% endblock %}
{% block content %}
<p>
{% blocktrans %}
We have sent you an email with a link to reset your password. Please check
your email and click the link to continue.
{% endblocktrans %}
</p>
{% endblock %}
{# This is used by django.contrib.auth #}
{% load i18n %}
{% blocktrans %}Greetings{% endblocktrans %} {% if user.get_full_name %}{{ user.get_full_name }}{% else %}{{ user }}{% endif %},
{% blocktrans %}
You are receiving this email because you (or someone pretending to be you)
requested that your password be reset on the {{ domain }} site. If you do not
wish to reset your password, please ignore this message.
{% endblocktrans %}
{% blocktrans %}
To reset your password, please click the following link, or copy and paste it
into your web browser:
{% endblocktrans %}
{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %}
{% blocktrans %}Your username, in case you've forgotten:{% endblocktrans %} {{ user.username }}
{% blocktrans %}Best regards{% endblocktrans %},
{{ site_name }} {% blocktrans %}Management{% endblocktrans %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Reset password" %}{% endblock %}
{% block content %}
<p>
{% blocktrans %}
Forgot your password? Enter your email in the form below and we'll send you instructions for creating a new one.
{% endblocktrans %}
</p>
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Reset password' %}" />
</form>
{% endblock %}
{# This is used by django.contrib.auth #}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Registration is closed" %}{% endblock %}
{% block content %}
<p>{% trans "Sorry, but registration is closed at this moment. Come back later." %}</p>
{% endblock %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Activation email sent" %}{% endblock %}
{% block content %}
<p>{% trans "Please check your email to complete the registration process." %}</p>
{% endblock %}
{% comment %}
**registration/registration_complete.html**
Used after successful completion of the registration form. This
template has no context variables of its own, and should simply inform
the user that an email containing account-activation information has
been sent.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Register for an account" %}{% endblock %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Submit' %}" />
</form>
{% endblock %}
{% comment %}
**registration/registration_form.html**
Used to show the form users will fill out to register. By default, has
the following context:
``form``
The registration form. This will be an instance of some subclass
of ``django.forms.Form``; consult `Django's forms documentation
<http://docs.djangoproject.com/en/dev/topics/forms/>`_ for
information on how to display this in a template.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Account Activation Resent" %}{% endblock %}
{% block content %}
<p>
{% blocktrans %}
We have sent an email to {{ email }} with further instructions.
{% endblocktrans %}
</p>
{% endblock %}
{% comment %}
**registration/resend_activation_complete.html**
Used after form for resending account activation is submitted. By default has
the following context:
``email``
The email address submitted in the resend activation form.
{% endcomment %}
{% extends "registration/registration_base.html" %}
{% load i18n %}
{% block title %}{% trans "Resend Activation Email" %}{% endblock %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Submit' %}" />
</form>
{% endblock %}
{% comment %}
**registration/resend_activation_form.html**
Used to show the form users will fill out to resend the activation email. By
default, has the following context:
``form``
The registration form. This will be an instance of some subclass
of ``django.forms.Form``; consult `Django's forms documentation
<http://docs.djangoproject.com/en/dev/topics/forms/>`_ for
information on how to display this in a template.
{% endcomment %}
......@@ -27,10 +27,10 @@ router.register(r'scores', views.ScoreViewSet)
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/', include('registration.backends.hmac.urls')),
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^', include('playground.urls')),
]
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
# cf <https://stackoverflow.com/questions/30871033/django-rest-framework-remove-csrf>
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return # To not perform the csrf check previously happening
......@@ -926,3 +926,48 @@ section.hidden {
display: inline-block;
padding-left: .25em;
}
.score-edit {
margin: 1em 0 1em 0;
}
.modalDialog {
position: fixed;