Commit 18a2baa214e893140f91fca2e009f12f05f6b2cd

Authored by Drew Baek ago
1 parent 1d6278d523
Exists in master

Add register function

Showing 17 changed files with 207 additions and 3 deletions Side-by-side Diff

distribute/forms.py View file @ 18a2baa
  1 +from django import forms
  2 +from django.core import validators
  3 +from django.contrib.auth.models import User
  4 +
  5 +class RegistrationForm(forms.Manipulator):
  6 + def __init__(self):
  7 + self.fields = (
  8 + forms.TextField(field_name='username',
  9 + length=30, maxlength=30,
  10 + is_required=True, validator_list=[validators.isAlphaNumeric,
  11 + self.isValidUsername]),
  12 + forms.EmailField(field_name='email',
  13 + length=30,
  14 + maxlength=30,
  15 + is_required=True),
  16 + forms.PasswordField(field_name='password1',
  17 + length=30,
  18 + maxlength=60,
  19 + is_required=True),
  20 + forms.PasswordField(field_name='password2',
  21 + length=30, maxlength=60,
  22 + is_required=True,
  23 + validator_list=[validators.AlwaysMatchesOtherField('password1',
  24 + 'Passwords must match.')]),
  25 + )
  26 +
  27 + def isValidUsername(self, field_data, all_data):
  28 + try:
  29 + User.objects.get(username=field_data)
  30 + except User.DoesNotExist:
  31 + return
  32 + raise validators.ValidationError('The username "%s" is already taken.' % field_data)
  33 +
  34 + def save(self, new_data):
  35 + u = User.objects.create_user(new_data['username'],
  36 + new_data['email'],
  37 + new_data['password1'])
  38 + u.is_active = False
  39 + u.save()
  40 + return u
distribute/forms.pyc View file @ 18a2baa

No preview for this file type

distribute/views.py View file @ 18a2baa
... ... @@ -23,6 +23,10 @@
23 23 return list
24 24  
25 25 @login_required(login_url='/accounts/login/')
  26 +def distribute(request):
  27 + return redirect("https://internal-release.pikicast.com")
  28 +
  29 +@login_required(login_url='/accounts/login/')
26 30 def index(request):
27 31 page = request.GET.get('page')
28 32 type = request.GET.get('type')
distribute/views.pyc View file @ 18a2baa

No preview for this file type

releasesite/settings.py View file @ 18a2baa
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import os.path
4 4  
  5 +ACCOUNT_ACTIVATION_DAYS = 1
  6 +
5 7 BASE_PATH = os.path.dirname(__file__)
6 8 LOGIN_REDIRECT_URL = '/distribute/'
7 9  
8 10  
9 11  
... ... @@ -128,15 +130,16 @@
128 130 'django.contrib.sites',
129 131 'django.contrib.messages',
130 132 'django.contrib.staticfiles',
  133 + 'django.contrib.humanize',
131 134 # Uncomment the next line to enable the admin:
132 135 'django.contrib.admin',
133 136 # Uncomment the next line to enable admin documentation:
134 137 # 'django.contrib.admindocs',
135   - 'django.contrib.sites',
136 138 #'django.contrib.flatpages',
137 139 #'django_mobile_app_distribution',
138 140 #'south',
139 141 'distribute',
  142 + 'registration',
140 143 )
141 144  
142 145 # A sample logging configuration. The only tangible logging
releasesite/settings.pyc View file @ 18a2baa

No preview for this file type

releasesite/urls.py View file @ 18a2baa
... ... @@ -16,11 +16,13 @@
16 16 # Uncomment the next line to enable the admin:
17 17 url(r'^admin/', include(admin.site.urls)),
18 18 url(r'^$', 'distribute.views.index'),
  19 + url(r'^distribute/', 'distribute.views.distribute'),
19 20 url(r'^put/', 'distribute.views.put'),
20 21 url(r'^patchset/', 'distribute.views.patchset'),
21 22 url(r'^put_patchset/', 'distribute.views.put_patchset'),
22   - url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
23   - url(r'^accounts/logout/$', 'distribute.views.logout_view'),
  23 + url(r'^accounts/', include('registration.backends.default.urls')),
  24 +# url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
  25 +# url(r'^accounts/logout/$', 'distribute.views.logout_view'),
24 26 #url(r'^$', include('django.contrib.flatpages.urls')),
25 27 #url(r'^distribute/', include('django_mobile_app_distribution.urls')),
26 28 #url(r'^accounts/', include('django_mobile_app_distribution.auth_urls')),
releasesite/urls.pyc View file @ 18a2baa

No preview for this file type

templates/distribute/index_patchset.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +{% block content %}
  3 +{% load staticfiles %}
  4 +
  5 +<section class="header">
  6 +<a class="button button-primary" href="https://internal-release.pikicast.com/">Release</a>
  7 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset">All</a>
  8 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset/?type=android">Android</a>
  9 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset/?type=ios">iOS</a>
  10 +</section>
  11 +<table data-role="table" class="u-full-width">
  12 +<thead>
  13 +<tr>
  14 +<td>Type</td>
  15 +<td>Date</td>
  16 +<td>ID</td>
  17 +<td>Open</td>
  18 +</tr>
  19 +</thead>
  20 +<tbody>
  21 +{% for item in items %}
  22 +<tr {% if item.is_publish %}bgcolor="#CCFFCC"{% endif %}>
  23 +<td><a href="{% if item.type == "ios" %}itms-services://?action=download-manifest&url=https://internal-release.pikicast.com/static/test/ios/NewPiki-{{ item.pub_date }}.plist{% else %}https://internal-release.pikicast.com/static/test/android/NewPiki-{{ item.pub_date }}.apk{% endif %}"><img src="/static/images/{{ item.type }}-icon.png" width="48px" height="48px" border="0"/></a></td>
  24 +<td>{{ item.pub_date }}</td>
  25 +<td>{{ item.last_commit|truncatechars:9 }}</td>
  26 +<td><a href="https://internal-release.pikicast.com/patchset/?pub_date={{ item.pub_date }}" target="_blank">New Window</a></td>
  27 +</tr>
  28 +</tbody>
  29 +{% endfor %}
  30 +</table>
  31 +<div class="pagination">
  32 + <span class="step-links">
  33 + {% if items.has_previous %}
  34 + <a href="?page={{ items.previous_page_number }}">previous</a>
  35 + {% endif %}
  36 +
  37 + <span class="current">
  38 + Page {{ items.number }} of {{ items.paginator.num_pages }}.
  39 + </span>
  40 +
  41 + {% if items.has_next %}
  42 + <a href="?page={{ items.next_page_number }}">next</a>
  43 + {% endif %}
  44 + </span>
  45 +</div>
  46 +{% endblock %}
templates/distribute/item_patchset.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +{% block content %}
  3 +{% load staticfiles %}
  4 +
  5 +<section class="header">
  6 +<a class="button button-primary" href="https://internal-release.pikicast.com/">Release</a>
  7 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset">All</a>
  8 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset/?type=android">Android</a>
  9 +<a class="button button-primary" href="https://internal-release.pikicast.com/patchset/?type=ios">iOS</a>
  10 +</section>
  11 +<table data-role="table" class="u-full-width">
  12 +<thead>
  13 +<tr>
  14 +<td>Type</td>
  15 +<td>Date</td>
  16 +<td>ID</td>
  17 +<td>Build</td>
  18 +</tr>
  19 +</thead>
  20 +<tbody>
  21 +{% for item in items %}
  22 +<tr {% if item.is_publish %}bgcolor="#CCFFCC"{% endif %}>
  23 +<td><a href="{% if item.type == "ios" %}itms-services://?action=download-manifest&url=https://internal-release.pikicast.com/static/test/ios/NewPiki-{{ item.pub_date }}.plist{% else %}https://internal-release.pikicast.com/static/test/android/NewPiki-{{ item.pub_date }}.apk{% endif %}"><img src="/static/images/{{ item.type }}-icon.png" width="48px" height="48px" border="0"/></a></td>
  24 +<td>{{ item.pub_date }}</td>
  25 +<td>{{ item.last_commit|truncatechars:9 }}</td>
  26 +<td>{{ item.app_version }}</td>
  27 +</tr>
  28 +<tr>
  29 +<td>Comment</td>
  30 +<td colspan="3">{{ item.comment }}</td>
  31 +</tr>
  32 +</tbody>
  33 +{% endfor %}
  34 +</table>
  35 +{% endblock %}
templates/registration/activate.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +
  3 +{% block title %}Account activation{% endblock %}
  4 +
  5 +{% block content %}
  6 +{% load humanize %}
  7 +<h2>Account activation</h2>
  8 +{% if account %}
  9 +<p>Thanks for signing up! Now you can <a href="/accounts/login/">log in</a> and start contributing!</p>
  10 +{% else %}
  11 +<p>Either your activation link was incorrect, or the activation key for your account has expired; activation keys are only
  12 +valid for {{ expiration_days|apnumber }} days after registration.</p>
  13 +{% endif %}
  14 +{% endblock %}
templates/registration/activation_complete.html View file @ 18a2baa
  1 +
  2 +{% extends "base.html" %}
  3 +
  4 +{% block content %}
  5 +
  6 +Your account activation completed :
  7 +
  8 +<a href="https://internal-release.pikicast.com/">Log in</a>
  9 +{% endblock %}
templates/registration/activation_email.txt View file @ 18a2baa
  1 +{% load humanize %}
  2 +Someone, hopefully you, signed up for a new account at https://internal-release.pikicast.com/ using this email address. If it was you, and you'd like to activate and used your account, click the link below or copy and paste it into your web browser's address bar:
  3 +
  4 +https://internal-release.pikicast.com/accounts/activate/{{ activation_key }}/
  5 +
  6 +If you didn't request this, you don't need to do anything; you won't receive any more email from us, and the account will expire automatically in {{ expiration_days|apnumber }} days.
templates/registration/activation_email_subject.txt View file @ 18a2baa
  1 +Pikicast Internal Release eamil confirmation
templates/registration/logout.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +
  3 +{% block title %}Logged out{% endblock %}
  4 +
  5 +{% block content %}
  6 +<h2>Logged out</h2>
  7 +
  8 +<p>You've been logged out.</p>
  9 +{% endblock %}
templates/registration/registration_complete.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +
  3 +{% block content %}
  4 +Registration complete. Please check your email.
  5 +{% endblock %}
templates/registration/registration_form.html View file @ 18a2baa
  1 +{% extends "base.html" %}
  2 +
  3 +{% block title %}Sign up{% endblock %}
  4 +
  5 +{% block content_header %}Sign up{% endblock %}
  6 +
  7 +{% block content %}
  8 +
  9 +{% if form.errors %}
  10 +<p class="error">Please correct the errors below:</p>
  11 +{% endif %}
  12 +
  13 +<form method="post" action="">{% csrf_token %}
  14 +<dl>
  15 +<dt><label for="id_username">Username:</label>{% if form.username.errors %} <span class="error">{{ form.username.errors|join:", " }}</span>{% endif %}</dt>
  16 +<dd>{{ form.username }}</dd>
  17 +<dt><label for="id_email">Email address:</label>{% if form.email.errors %} <span class="error">{{ form.email.errors|join:", " }}</span>{% endif %}</dd>
  18 +<dd>{{ form.email }}</dd>
  19 +<dt><label for="id_password1">Password:</label>{% if form.password1.errors %} <span class="error">{{ form.password2.errors|join:", " }}</span>{% endif %}</dt>
  20 +<dd>{{ form.password1 }}</dd>
  21 +<dt><label for="id_password2">Password (type again to catch any typos):</label>{% if form.password2.errors %} <span class="error">{{ form.password2.errors|join:", " }}</span>{% endif %}</dt>
  22 +<dd>{{ form.password2 }}</dd>
  23 +<dt><input type="submit" value="Register" /></dt>
  24 +</dl>
  25 +</form>
  26 +{% endblock %}
  27 +
  28 +{% block sidebar %}
  29 +<p>Fill out the form to the left (all fields are required), and your account will be created; you'll be sent an email with instructions on how to finish your registration.</p>
  30 +{% endblock %}