Mercurial > hg > agora-dellsystem
changeset 23:d9658d30b814
Implement initial user registration and authentication. Still way buggy.
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Sun, 27 Jun 2010 21:56:57 -0500 |
parents | 37ced16ff95e |
children | 2e7226e90157 |
files | apps/bundle/urls.py settings-example.py templates/base.djhtml templates/bundle/index.djhtml templates/controls.djhtml templates/registration/activate.html templates/registration/activation_email.txt templates/registration/activation_email_subject.txt templates/registration/login.html templates/registration/registration_complete.html templates/registration/registration_form.html urls.py |
diffstat | 12 files changed, 198 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/apps/bundle/urls.py +++ b/apps/bundle/urls.py @@ -2,7 +2,5 @@ urlpatterns = patterns('agora.apps.bundle.views', (r'^(?P<user>.*)/(?P<bundle>.*)/$', 'detail'), - (r'^(?P<user>.*)/$', 'index'), - )
--- a/settings-example.py +++ b/settings-example.py @@ -93,6 +93,9 @@ "templates", #Relative paths are ok for testing ) +#For how long a registration link will remain active +ACCOUNT_ACTIVATION_DAYS = 1 + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', @@ -102,6 +105,9 @@ 'django.contrib.admindocs', 'django.contrib.admin', + #Third-party apps + 'registration', + #Agora-specific apps 'agora.apps.snippet', 'agora.apps.bundle',
--- a/templates/base.djhtml +++ b/templates/base.djhtml @@ -5,7 +5,11 @@ <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> - <title>Agora Octave — {% block title %}Free your math!{% endblock %}</title> + <title>Agora Octave — + {% block title %} + Free your math! + {% endblock %} + </title> <meta name="Copyright" content="Agora Octave is free software under the Affero General Public License version 3 as published by @@ -21,7 +25,7 @@ <link href="/static/{% block cssid %}base{% endblock %}.css" rel="stylesheet" type="text/css" media="screen" /> - {% block extrahead %}{% endblock %} + {% block extrahead %}{% endblock %} </head> <body id="{% block sectionid %}generic{% endblock %}" @@ -30,7 +34,7 @@ <div id="container"> <div id="header"> <img src="/static/agora.png" id="agora-logo"> - <h1 id="logo"><a href="http://www.octave.org/">Agora Octave</a> + <h1 id="logo"><a href="/">Agora Octave</a> </h1> <div id="nav"> <div id="nav-top"></div>
--- a/templates/bundle/index.djhtml +++ b/templates/bundle/index.djhtml @@ -2,13 +2,13 @@ {% block content %} <div class="info"> - {% if bundle %} <h3> {{bundle.name}} by <a href="/{{bundle.uploader}}/">{{bundle.uploader}}</a> </h3> + {% if files %} + <div class="whitebox"> - {% if files %} <p> files: </p> @@ -20,14 +20,14 @@ </div> {% else %} - <p> - No files in this bundle! - </p> + + <div class="whitebox"> + <p> + No files in this bundle! + </p> + </div> + {% endif %} - - {% else %} - Bundle not found! - {% endif %} </div> {% endblock %}
--- a/templates/controls.djhtml +++ b/templates/controls.djhtml @@ -1,9 +1,30 @@ {% extends "base.djhtml" %} {% block content-related %} -<div class="whitebox"> - <p> - stuff stuff stuff - </p> +<div id="info"> + <h3> + Controls + </h3> + <div class="whitebox"> + {% if user.is_authenticated %} + <p> + You are logged in + as <a href="/{{user.username}}">{{user.username}}</a>. + </p> + <p> + (<a href="{% url auth_logout %}">logout</a>) + </p> + {% else %} + <p> + <a href="/accounts/login">Log in</a> + </p> + {% endif %} + <form method="get" action="." > + <br/> + <input id="search" type="text" name="search" maxlength="200" size="10"/> + <input type="submit" value="Search" /> + </form> + + </div> </div> {% endblock %}
new file mode 100644 --- /dev/null +++ b/templates/registration/activate.html @@ -0,0 +1,25 @@ +{% extends "controls.djhtml" %} + +{% block content %} +<div id="info"> + <h3> + Account activation + </h3> + <div class="whitebox"> + {% if account %} + <p> + Account successfully activated. + <a href="{% url auth_login%}">Click here</a> to log in. + </p> + + {% else %} + + <p> + Account activation failed" %} + </p> + + {% endif %} + + </div> +</div> +{% endblock %}
new file mode 100644 --- /dev/null +++ b/templates/registration/activation_email.txt @@ -0,0 +1,10 @@ +You are receiving this email because you requested a registration for +Agora Octave (http://{{ site.domain }})). Please click the following +link to complete your registration to Agora Octave: + + http://{{ site.domain }}{% url registration_activate activation_key %} + +This link is valid for {{ expiration_days }} days. + +If you received this email in error, simply ignore it, and we +apologise for the inconvenience.
new file mode 100644 --- /dev/null +++ b/templates/registration/activation_email_subject.txt @@ -0,0 +1,1 @@ +Agora Octave registration
new file mode 100644 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,50 @@ +{% extends "controls.djhtml" %} + +{% block content %} +<div id="info"> + <h3> + Login + </h3> + <div class="whitebox"> + {% if user.is_authenticated %} + <p> + You're already logged in as + <a href="{{ user.username }}">{{user.username}}</a>. + </p> + <p> + (<a href="{% url auth_logout %}">logout</a>) + </p> + + {% else %} + + {% if form.errors %} + <p>{{form.errors}}</p> + {% endif %} + <form method="post" action="."> + {% csrf_token %} + <p> + <label for="id_username">Username:</label> + <br/> + <input id="id_username" type="text" name="username" maxlength="30" /> + </p> + <p> + <label for="id_password">Password:</label> + <br/> + <input type="password" name="password" id="id_password" /> + </p> + <input type="submit" value="Log in" /> + <input type="hidden" name="next" value="{{ next }}" /> + </form> + + <p> + Forgot password? <a href="{% url auth_password_reset %}">Reset it</a>! + </p> + <p> + Not member? <a href="{% url registration_register %}">Register</a>! + </p> + {% endif %} + + + </div> +</div> +{% endblock %}
new file mode 100644 --- /dev/null +++ b/templates/registration/registration_complete.html @@ -0,0 +1,9 @@ +{% extends "controls.djhtml" %} +{% block content %} +<div class="whitebox"> + <p> + Activation email sent. Please check your inbox to complete your + registration. + </p> +</div> +{% endblock %}
new file mode 100644 --- /dev/null +++ b/templates/registration/registration_form.html @@ -0,0 +1,45 @@ +{% extends "controls.djhtml" %} + +{% block content %} + +<div class="info"> + <h3> + Registration details + </h3> + <div class="whitebox"> + <p> + Please provide us some basic information to set up your account. + </p> + <form action="." method="post"> + {% csrf_token %} + <p> + <label for="id_username">username: (letters, numbers, underscores) + </label> + <br /> + <input id="id_username" type="text" class="required" + name="username" maxlength="30" /> + </p> + <p> + <label for="id_email">email address:</label> + <br /> + <input id="id_email" type="text" class="required" name="email" + maxlength="75" /> + </p> + <p> + <label for="id_password1">password:</label> + <br /> + <input id="id_password1" type="password" class="required" + name="password1" /> + </p> + <p> + <label for="id_password2">password (again):</label> + <br /> + <input id="id_password2" type="password" class="required" + name="password2" /> + </p> + <input class="button" type="submit" value="Submit" /> + </form> + </div> +</div> + +{% endblock %}
--- a/urls.py +++ b/urls.py @@ -5,17 +5,21 @@ admin.autodiscover() urlpatterns = patterns('', - - (r'^$', - 'django.views.generic.simple.direct_to_template', - {'template': 'index.djhtml'}), + (r'^$', + 'django.views.generic.simple.direct_to_template', + {'template': 'index.djhtml'}), - (r'^admin/doc/', include('django.contrib.admindocs.urls')), + (r'^admin/doc/', include('django.contrib.admindocs.urls')), + (r'^admin/', include(admin.site.urls)), - (r'^admin/', include(admin.site.urls)), + (r'^accounts/logout/', 'django.contrib.auth.views.logout', + {'template_name' : 'index.djhtml', 'next_page' : '/'}), - (r'^', include('agora.apps.bundle.urls')) + (r'^accounts/', include('registration.urls'), + {'template_name' : 'registration/registration_form.djhtml'} ), + + (r'^', include('agora.apps.bundle.urls')), )