Browse files

Allow editing of first and last name.

Signed-off-by: Chris Lamb <lamby@debian.org>
  • Loading branch information...
1 parent b4c9ae3 commit f7cf2fdd6cf947a42cd2cd5cb981cc761a94f122 @lamby lamby committed with Sep 28, 2012
Showing with 26 additions and 0 deletions.
  1. +14 −0 src/librement/profile/forms.py
  2. +12 −0 src/templates/profile/edit/account.html
View
14 src/librement/profile/forms.py
@@ -24,6 +24,14 @@ class Meta:
'rss_url',
)
+class AccountUserForm(forms.ModelForm):
+ class Meta:
+ model = User
+ fields = (
+ 'first_name',
+ 'last_name',
+ )
+
class AccountProfileForm(forms.ModelForm):
class Meta:
model = Profile
@@ -51,6 +59,12 @@ class AccountForm(dict):
def __init__(self, user, *args, **kwargs):
self.user = user
+ self['user'] = AccountUserForm(
+ instance=user,
+ *args,
+ **kwargs
+ )
+
self['profile'] = AccountProfileForm(
instance=user.profile,
*args,
View
12 src/templates/profile/edit/account.html
@@ -7,6 +7,18 @@
<form method="POST" action="" class="form-horizontal">
{% csrf_token %}
+ <div class="control-group {% if form.user.errors.first_name or form.user.errors.last_name %}error{% endif %}">
+ <label class="control-label" for="{{ form.user.first_name.id_for_label }}">Name</label>
+ <div class="controls">
+ <input type="text" id="{{ form.user.first_name.id_for_label }}" name="{{ form.user.first_name.html_name }}" placeholder="First name" value="{{ form.user.first_name.value|default:"" }}">
+ <input type="text" id="{{ form.user.last_name.id_for_label }}" name="{{ form.user.last_name.html_name }}" placeholder="Last name" value="{{ form.user.last_name.value|default:"" }}">
+ <span class="help-inline">
+ {% for x in form.user.errors.first_name %}{{ x }}{% endfor %}
+ {% for x in form.user.errors.last_name %}{{ x }}{% endfor %}
+ </span>
+ </div>
+ </div>
+
<div class="control-group {% if form.profile.errors.organisation %}error{% endif %} {% if form.profile.account_type.value == "individual" %}hide{% endif %}">
<label class="control-label" for="{{ form.profile.organisation.id_for_label }}">Organisation</label>
<div class="controls">

0 comments on commit f7cf2fd

Please sign in to comment.