euscanwww: Improved forms UI, added preferences page and change password

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-08-08 10:46:36 +02:00
parent c4e3c4c04a
commit 77f1cb52ea
15 changed files with 140 additions and 56 deletions

View File

@ -1,6 +1,6 @@
from django import forms
from djeuscan.models import Package, Version, ProblemReport
from djeuscan.models import Version, ProblemReport
class WorldForm(forms.Form):
@ -27,3 +27,9 @@ class ProblemReportForm(forms.ModelForm):
class Meta:
model = ProblemReport
fields = ('version', 'subject', 'message')
class PreferencesForm(forms.Form):
first_name = forms.CharField(max_length=30, required=False)
last_name = forms.CharField(max_length=30, required=False)
email = forms.EmailField()

View File

@ -8,8 +8,19 @@
{% block content %}
<h2>Welcome {{ user }}</h2>
<h2>
Welcome {{ user }}
<span class="pull-right">
<a href="{% url "auth_password_change" %}" class="btn">
Change password
</a>
<a href="{% url "accounts_preferences" %}" class="btn">
Preferences
</a>
</span>
</h2>
<h3 class="padded">Summary</h3>

View File

@ -0,0 +1,32 @@
{% extends "_base.html" %}
{% load url from future %}
{% block title %}
{{ block.super }} - Edit user preferences for {{ user }}
{% endblock %}
{% block content %}
{% if updated %}
<div class="alert alert-success">
<strong>Saved!</strong> Your preferences has been saved
</div>
{% endif %}
<h2>
Edit user preferences
</h2>
<form method='post' action='.'>
{% csrf_token %}
<table class="table">
{{ form }}
<tr>
<td></td>
<td>
<input class="btn" type='submit' value="Save" />
</td>
</tr>
</table>
</form>
{% endblock %}

View File

@ -15,7 +15,7 @@
<form action="{% url "world_scan" %}" method="post" enctype="multipart/form-data">{% csrf_token %}
{{ world_form.as_p }}
<input type="submit" value="Submit" />
<input class="btn" type="submit" value="Submit" />
</form>
<hr />
@ -24,7 +24,7 @@
<form action="{% url "world_scan" %}" method="post">{% csrf_token %}
{{ packages_form.as_p }}
<input type="submit" value="Submit" />
<input class="btn" type="submit" value="Submit" />
</form>
{% endblock %}

View File

@ -5,12 +5,18 @@
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
<div class="alert alert-error">
<strong>Error:</strong> Your username and password didn't match. Please try again.
</div>
{% endif %}
<form method="post" action="{% url 'django.contrib.auth.views.login' %}">
<h2>
Login
</h2>
<form method="post" action="{% url "auth_login" %}">
{% csrf_token %}
<table>
<table class="table">
<tr>
<th>{{ form.username.label_tag }}</th>
<td>{{ form.username }}</td>
@ -27,10 +33,10 @@
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
</td>
<td></td>
<td>
<a class="pull-right" href="{% url "django.contrib.auth.views.password_reset" %}">Forgot password</a>
</td>

View File

@ -1,13 +0,0 @@
{% extends "registration/_registration_base.html" %}
{% load i18n %}
{% block content %}
<p>You're logged out."</p>
<p>Redirect...</p>
<script type="text/javascript">
window.location.href = "/";
</script>
{% endblock %}

View File

@ -1,6 +0,0 @@
{% extends "registration/_registration_base.html" %}
{% block title %}Password changed{% endblock %}
{% block content %}
Password successfully changed!
{% endblock %}

View File

@ -1,14 +1,22 @@
{% extends "registration/_registration_base.html" %}
{% load url from future %}
{% block title %}Change password{% endblock %}
{% block content %}
<form method='post' action=''>{% csrf_token %}
<table>
<h2>
Change password
</h2>
<form method='post' action='.'>
{% csrf_token %}
<table class="table">
{{ form }}
<tr>
<td></td>
<td>
<input type='submit' value="Change password" />
<input class="btn" type='submit' value="Change password" />
</td>
</tr>
</table>

View File

@ -2,9 +2,15 @@
{% block title %}Confirm password reset{% endblock %}
{% block content %}
Enter your new password below to reset your password:
<h2>
Reset password
</h2>
<p class="padded">
Enter your new password below to reset your password:
</p>
<form method="post" action="">{% csrf_token %}
<table>
<table class="table">
{{ form.as_table }}
<tr>
<td></td>

View File

@ -3,15 +3,21 @@
{% block title %}Reset password{% endblock %}
{% block content %}
<h2>
Reset password
</h2>
<p class="padded">
Forgot your password? Enter your email in the form below and we'll send you
instructions for creating a new one.
</p>
<form method='post' action=''>{% csrf_token %}
<table>
<table class="table">
{{ form }}
<tr>
<td></td>
<td><input type='submit' value="Reset password" /></td>
<td><input class="btn" type='submit' value="Reset password" /></td>
</tr>
</table>
</form>

View File

@ -5,8 +5,12 @@
{% endblock %}
{% block content %}
<h2>
Register
</h2>
<form method='post' action=''>{% csrf_token %}
<table>
<table class="table">
{{ form }}
<tr>
<td></td>

View File

@ -1,5 +1,7 @@
from django.conf.urls.defaults import url, patterns, include
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.views import logout
from django.views.generic import RedirectView
from djcelery.views import apply as apply_task
from djeuscan.views import registered_tasks
@ -83,12 +85,19 @@ tasks_patterns = patterns('djeuscan.views',
accounts_patterns = patterns('djeuscan.views',
url(r'^profile/$', 'accounts_index', name="accounts_index"),
url(r'^profile/preferences/$', 'accounts_preferences',
name="accounts_preferences"),
url(r'^categories/$', 'accounts_categories', name="accounts_categories"),
url(r'^herds/$', 'accounts_herds', name="accounts_herds"),
url(r'^maintainers/$', 'accounts_maintainers',
name="accounts_maintainers"),
url(r'^packages/$', 'accounts_packages', name="accounts_packages"),
url(r'^overlays/$', 'accounts_overlays', name="accounts_overlays"),
url(r'^logout/$', logout, {'next_page': '/'}),
url(r'^password/change/done/$',
RedirectView.as_view(url="../../../profile/")),
)

View File

@ -12,7 +12,8 @@ from djeuscan.helpers import version_key, packages_from_names, get_profile, \
get_account_categories, get_account_herds, get_account_maintainers
from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \
VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay
from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm
from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm, \
PreferencesForm
from djeuscan.tasks import admin_tasks
from djeuscan import charts
@ -415,6 +416,29 @@ def accounts_index(request):
}
@login_required
@render_to('euscan/accounts/preferences.html')
def accounts_preferences(request):
user = request.user
updated = False
if request.method == "POST":
form = PreferencesForm(request.POST)
if form.is_valid():
user.first_name = form.cleaned_data["first_name"]
user.last_name = form.cleaned_data["last_name"]
user.email = form.cleaned_data["email"]
user.save(force_update=True)
updated = True
else:
initial_data = {
"first_name": user.first_name,
"last_name": user.last_name,
"email": user.email
}
form = PreferencesForm(initial_data)
return {"form": form, "updated": updated}
@login_required
@render_to('euscan/accounts/categories.html')
def accounts_categories(request):

View File

@ -5,13 +5,11 @@ admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^', include('djeuscan.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('captcha.backends.default.urls')),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^', include('djeuscan.urls')),
)

View File

@ -125,25 +125,13 @@ hr {
}
table {
max-width: 60em;
/* width: 50%; */
border-collapse: collapse;
font-size: 1em;
margin-left: auto;
margin-right: auto;
background: #F5F5F5;
text-align: left;
.table {
width: 60% !important;
margin: auto;
}
td {
vertical-align: top;
}
th {
font-size: 0.8em;
text-align: center;
border-bottom: 3px solid;
max-width: 350px;
}
#footer {
@ -245,3 +233,8 @@ th {
textarea {
width: inherit;
}
.errorlist > li {
color: red;
list-style: none;
}