From 0e26988867e0389ad42e9886fb5c89dc1d0aefa5 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 29 Sep 2013 16:22:42 +0200 Subject: [PATCH] User Profile & URL Cleanup --- blechreiz/database.sqlite | Bin 53248 -> 53248 bytes blechreiz/urls.py | 25 ++++++++---------- .../templates/eventplanner/events_grid.html | 6 +++-- musicians/models.py | 3 ++- .../templates/musicians/musician_edit.html | 7 +++-- musicians/tests.py | 16 ----------- musicians/urls.py | 11 ++++++++ musicians/views.py | 12 ++++++--- website/templates/website/base.html | 9 +++---- 9 files changed, 43 insertions(+), 46 deletions(-) delete mode 100644 musicians/tests.py create mode 100644 musicians/urls.py diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index ae8a44d3a1bc99f8b00e5f56da2ce29e344d4906..b979c29a7283e4a14f7c30ffcd419bf228474409 100644 GIT binary patch delta 871 zcmaKqO=uHA6vt=wwb9hIDz$29(f9#9XyeXIHoFt>W7U3GyQ?WNW`n5drtLPH)TC{i zwjga4^s4MhQ1GG`Pa32sNJXho1&bhvpn~YZ4@3~eLp``{FG9h0n|VJT@Bf>bxB(M4 z;Bq~lyV7tF&)qq5i}|i0hzi%r>%?!^hfku(M$Jtsr`GX+#3PJELQ0T(r4skCBCVXH z!s>qz5{eKtLV1u7MpfBE_Et~s!i$K%zHTG)yJwUQ?u+mNZ=MHBYD5YLxy-mi-E-kB zE?4UAs+DV32w#!#Re0xZ@kkiQVf{i;;}RK37kav=d=??RU7yswD|;Y+zDB6jFUU&= zC(BEPF*dB0N_>zMOZiM*8Fp+|Nau`LGN+F<%Vx~BjT6Z}J*G)|#>gde$3yxdM=~;L z+h~pFj1$cvBW9M4#`IA$R?sx}$dS-^TYKK@lkIe(^K3`1-8Sh^wky{;*5Q!hWNUmd znrq3VXuOzgYd#c@k{&Y=mr^a9STsJGpjpR?c6Mml-ea0q31(z1X5_sjJ;{V!N+sH5 zD;n?6+Kv~gL|7A%nh0Cav*eO060N3k6}&|lrVvcQThGgFIJ^UNyr|$msRe}4j$UV| zN6lCR;Q=Q-!ikd^B>CbnldVxUq$*v7yT>Y4Hi$?@a2;A;lWiiBv85`{4iw6nXb+pDq&8Q73EdE^P+DS!6%sYQa*(GI>CqhxMrtd zb`Q1}?P4*|XW0QK)!!c|e=2PY`92`{08c#l0VMY<7pMjmHLOsw88p1S%YzGgsVr1^ zqC}WM@CSawPxua>;Um0@7GlSF#7tAIsm)9_ z)1eEuN>*J6b>pIlV1o*7Du@rNAcA0p>Y{d`3lRiyQ3dbJ;6_lF|M`B-Isf6zF2L*p zT`zEs2d5;2mK&={c`4PlZ7b9e z)Yx}){6n_JNC+_knX|Qv?)YWJ6shbZb)prg%DEgBon%gIiHUMa%3qR9#jKP~N1m!w zC49kg@`{X!U|?g^;D}XnbvtY8Ua6wnM9>FJQy(;{#LHk>6SAX6&yzvoQ6DDOl&1MZ zL&;i=X(RQxHkr@O6!XR$bY#)&D|5jc)zNNi8id+QOAq`#ZUDjY(CSdZ+PV@x1 z{&>3)xMT4Szc+Rzh?X{Ep;ZJMuu6A$0kH@hLSbe{oHYtgu;K1chSm|R!y`%`z}O#o z8s8xF3!KOc80`fu{I|HRv{6_=@B_ZXSNIGc;RC#fx9}QX!V2wv3;dNp?T*4Sf=&1W ZpD2F=ui!a6hGqB$jo-Ne!Sa2r>lfv$+1daA diff --git a/blechreiz/urls.py b/blechreiz/urls.py index 775f289..258b802 100644 --- a/blechreiz/urls.py +++ b/blechreiz/urls.py @@ -2,29 +2,26 @@ from django.conf.urls import patterns, include, url from django.contrib import admin -from musicians.views import MusicianList, addressbook -from musicians.views import user_edit - import website.views import simpleforum.views import eventplanner.urls +import musicians.urls + + import settings from django.conf.urls.static import static admin.autodiscover() urlpatterns = patterns('', - url(r'$^', website.views.home_view ), - url(r'^events/', include( eventplanner.urls.urlpatterns) ), - url(r'^admin/', include(admin.site.urls) ), - url(r'^admin/doc/', include('django.contrib.admindocs.urls') ), - url(r'^musicians/$', MusicianList.as_view() ), - url(r'^musicians/(?P[\w]+)$', user_edit ), - url(r'^addressbook/$', addressbook ), - url(r'^login/$', website.views.login_view), + url(r'$^', website.views.home_view ), + url(r'^login/$', website.views.login_view), url(r'^login/usernames$', website.views.userlistForAutocompletion), - url(r'^logout/$', website.views.logout_view), - url(r'^messages/$', simpleforum.views.message_view ), - url(r'^location_field/', include('location_field.urls')), + url(r'^logout/$', website.views.logout_view), + url(r'^events/', include( eventplanner.urls.urlpatterns) ), + url(r'^musicians/', include( musicians.urls.urlpatterns) ), + url(r'^messages/$', simpleforum.views.message_view ), + url(r'^admin/', include(admin.site.urls) ), + url(r'^location_field/', include('location_field.urls')), ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/eventplanner/templates/eventplanner/events_grid.html b/eventplanner/templates/eventplanner/events_grid.html index bf68f17..1629652 100644 --- a/eventplanner/templates/eventplanner/events_grid.html +++ b/eventplanner/templates/eventplanner/events_grid.html @@ -28,9 +28,11 @@ {% addtoblock "js" %} {% endaddtoblock %} diff --git a/musicians/models.py b/musicians/models.py index 22335f7..ccc4d33 100644 --- a/musicians/models.py +++ b/musicians/models.py @@ -43,6 +43,8 @@ class Musician( models.Model ): position = models.IntegerField( null=True, verbose_name=_("Position") ) + public_description = models.TextField( blank=True, verbose_name=_("public_description") ) + @property def isDeepBrass(self): return self.instrument == 'TRB' or self.instrument == "EUPH" or self.instrument == "TUBA" or self.instrument == "HRN" @@ -51,7 +53,6 @@ class Musician( models.Model ): def isHighBrass(self): return self.instrument == 'TR' - public_description = models.TextField( blank=True, verbose_name=_("public_description") ) def __unicode__( self ): return self.user.username diff --git a/musicians/templates/musicians/musician_edit.html b/musicians/templates/musicians/musician_edit.html index 7f07fd5..f41de8c 100644 --- a/musicians/templates/musicians/musician_edit.html +++ b/musicians/templates/musicians/musician_edit.html @@ -18,19 +18,18 @@
-

{{user.first_name}} {{user.last_name}}

+

{{musician.user.first_name}} {{musician.user.last_name}}

{% csrf_token %} {{ form }}
- +
- +
-
diff --git a/musicians/tests.py b/musicians/tests.py deleted file mode 100644 index 501deb7..0000000 --- a/musicians/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase - - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2) diff --git a/musicians/urls.py b/musicians/urls.py new file mode 100644 index 0000000..196976c --- /dev/null +++ b/musicians/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls import patterns, url + +import musicians.views + + +urlpatterns = patterns('', + url(r'^$', musicians.views.addressbook ), + url(r'^profile$', musicians.views.own_profile ), + url(r'^(?P[\w]+)$$', musicians.views.user_edit ), +) + diff --git a/musicians/views.py b/musicians/views.py index 911b1c9..129d6cf 100644 --- a/musicians/views.py +++ b/musicians/views.py @@ -36,15 +36,19 @@ class UserEditForm( forms.ModelForm ): def save(self): if self.is_valid(): super(UserEditForm,self).save() - self.instance.user.email = self.cleaned_data['email'] + self.instance.user.email = self.cleaned_data['email'] self.instance.user.save() class Meta: model = Musician - exclude = [ 'user','image', 'instrument' ] + exclude = [ 'user','image', 'small_image', 'instrument', 'position', 'public_description' ] #fields = '__all__' +def own_profile( request ): + return user_edit( request, request.user ) + + def user_edit( request, username ): musician = get_object_or_404( Musician, user__username=username ) @@ -53,11 +57,11 @@ def user_edit( request, username ): form.instance = musician if form.is_valid(): # All validation rules pass form.save() - return HttpResponseRedirect('/musicians/' + username) # Redirect after POST + return HttpResponseRedirect('/') # Redirect after POST else: form = UserEditForm( instance= musician ) - return render(request, 'musicians/musician_edit.html', { 'form': form, } ) + return render(request, 'musicians/musician_edit.html', { 'form': form, 'musician': musician } ) diff --git a/website/templates/website/base.html b/website/templates/website/base.html index 1300996..ffbc0ae 100644 --- a/website/templates/website/base.html +++ b/website/templates/website/base.html @@ -103,21 +103,20 @@ $.ajaxSetup({