Skip to content

Commit

Permalink
put 'My Reports' in main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
visiblegovernment committed Jul 20, 2011
1 parent bd1971f commit 020985f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 15 deletions.
25 changes: 23 additions & 2 deletions mainapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,32 @@ def clean(self, value):


class EditProfileForm(forms.ModelForm):

first_name = forms.CharField()
last_name = forms.CharField()

class Meta:
model = UserProfile
fields = ( 'phone',)
fields = ( 'first_name','last_name','phone',)



RELATED_FIELD_MAP = {
'first_name': 'first_name',
'last_name': 'last_name',
}

def __init__(self, *args, **kwargs):
super(EditProfileForm, self).__init__(*args, **kwargs)
if self.instance.id:
for field, target_field in self.RELATED_FIELD_MAP.iteritems():
self.initial[ field ] = getattr(self.instance.user, target_field )

def save(self, *args, **kwargs):
for field, target_field in self.RELATED_FIELD_MAP.iteritems():
setattr(self.instance.user,target_field, self.cleaned_data.get(field))
self.instance.user.save()
super(EditProfileForm, self).save(*args, **kwargs)

class ReportUpdateForm(forms.ModelForm):

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions mainapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,10 @@ class UserProfile(models.Model):
# can edit through the admin
# panel.

cities = models.ManyToManyField(City, null=True)
cities = models.ManyToManyField(City, null=True,blank=True)

# fields for 'non-admin' users:
phone = models.CharField(max_length=255, verbose_name = ugettext_lazy("Phone"), null=True )
phone = models.CharField(max_length=255, verbose_name = ugettext_lazy("Phone"), null=True, blank=True )


def __unicode__(self):
Expand Down
8 changes: 7 additions & 1 deletion mainapp/templatetags/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
},
'view' : { 'exact': [],
'startswith' : [ '/cities','/wards', '/reports' ],
'exclude':[ '/reports/new' ] }
'exclude':[ '/reports/new' ]
},
'myreports' : { 'exact' : [],
'startswith' : [ '/accounts' ],
'exclude' : [] },


}

def is_match( path, pattern ):
Expand Down
3 changes: 1 addition & 2 deletions mainapp/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def home( request ):
page = paginator.page(paginator.num_pages)

return render_to_response("account/home.html",
{"profile": request.user.get_profile(),
'reports':page.object_list,
{'reports':page.object_list,
'page':page },
context_instance=RequestContext(request))

Expand Down
2 changes: 1 addition & 1 deletion templates/account/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% block title %}{% trans "Edit Profile" %}{% endblock %}
{% block content %}
<div id='profile-form'>
<h3>{% trans "Editing Profile For" %} {{user.first_name}} {{user.last_name}}</h3>
<h3>{% trans "Editing User Profile For" %} {{user.first_name}} {{user.last_name}}</h3>
<form action="/accounts/edit/" method="POST">{% csrf_token %}
<table class='form'>
{{form.as_table}}
Expand Down
5 changes: 0 additions & 5 deletions templates/account/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
{% block title %}My Reports{% endblock %}

{% block content %}
<div id='profile-menu'>
<ul>
<li><a href='/accounts/edit/'>Edit Profile</a></li>
</ul>
</div>
<h2>My Reports</h2>
{% include "reports/_pagination.html" %}
<table class='myreports'>
Expand Down
8 changes: 6 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
<div id='account-signin'>
<ul>
{% if user.is_authenticated %}
<li><a href='{% url account_home %}'>My Account</a></li>
{% if user.is_staff %}
<li><a href='/admin'>Admin</a></li>
{% endif %}
<li><a href='{% url account_edit %}'>My Account</a></li>
<li><a href='{% url auth_logout %}'>Sign Out</a></li>
{% else %}
<li><a href='{% url auth_login %}'>Sign In</a></li>
Expand Down Expand Up @@ -70,8 +73,8 @@
<ul>
<li><a class="{% fmsmenu_active request 'submit' %}" href="/" >{% trans "Submit a Report" %}</a></li>
<li><a class="{% fmsmenu_active request 'view' %}" href="{{cities_link}}">{% trans "View Reports" %}</a></li>
<li><a class="{% fmsmenu_active request 'myreports' %}" href="{% url account_home %}">{% trans "My Reports" %}</a></li>
<li><a class="{% fmsmenu_active request about %}" href="{{about}}">{% trans "About" %}</a></li>
<li><a class="{% fmsmenu_active request contact %}" href="{{contact}}">{% trans "Contact Us" %}</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -102,6 +105,7 @@
<div class='grid_12'>
<a href="http://visiblegovernment.ca">VisibleGovernment.ca</a>
| <a href='{% url privacy %}'>{% trans "Privacy" %}</a></p>
| <a href='{% url contact_url_name %}'>{% trans "Contact Us" %}</a></p>
| <a href='{% url posters %}'>{% trans "Hang a Poster" %}</a>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions templates/registration/registration_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
</div>
{% endif %}
<h3>{% trans "Join FixMyStreet.ca!" %}</h3>
{% if social_connect %}
<p>{% trans "We need a few more pieces of information to continue..." %}
{% endif %}
<form action="{% url registration_register %}" method="POST">{% csrf_token %}
<table class='form'>
{{form.as_table}}
Expand Down

0 comments on commit 020985f

Please sign in to comment.