User Profile & URL Cleanup
This commit is contained in:
parent
d71c35bcd7
commit
0e26988867
Binary file not shown.
|
@ -2,29 +2,26 @@ from django.conf.urls import patterns, include, url
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from musicians.views import MusicianList, addressbook
|
|
||||||
from musicians.views import user_edit
|
|
||||||
|
|
||||||
import website.views
|
import website.views
|
||||||
import simpleforum.views
|
import simpleforum.views
|
||||||
|
|
||||||
import eventplanner.urls
|
import eventplanner.urls
|
||||||
|
import musicians.urls
|
||||||
|
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'$^', website.views.home_view ),
|
url(r'$^', website.views.home_view ),
|
||||||
url(r'^events/', include( eventplanner.urls.urlpatterns) ),
|
url(r'^login/$', website.views.login_view),
|
||||||
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<username>[\w]+)$', user_edit ),
|
|
||||||
url(r'^addressbook/$', addressbook ),
|
|
||||||
url(r'^login/$', website.views.login_view),
|
|
||||||
url(r'^login/usernames$', website.views.userlistForAutocompletion),
|
url(r'^login/usernames$', website.views.userlistForAutocompletion),
|
||||||
url(r'^logout/$', website.views.logout_view),
|
url(r'^logout/$', website.views.logout_view),
|
||||||
url(r'^messages/$', simpleforum.views.message_view ),
|
url(r'^events/', include( eventplanner.urls.urlpatterns) ),
|
||||||
url(r'^location_field/', include('location_field.urls')),
|
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)
|
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
@ -28,9 +28,11 @@
|
||||||
|
|
||||||
{% addtoblock "js" %}
|
{% addtoblock "js" %}
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
{% if not perms.eventplanner.change_others_participation %}
|
{% if not perms.eventplanner.change_others_participation %}
|
||||||
$(".eventButton").attr('disabled', 'disabled');
|
$(".eventButton").attr('disabled', 'disabled');
|
||||||
|
$(".deleteButton").hide();
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$('.eventButton').tooltip()
|
$('.eventButton').tooltip()
|
||||||
|
@ -97,7 +99,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endaddtoblock %}
|
{% endaddtoblock %}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ class Musician( models.Model ):
|
||||||
|
|
||||||
position = models.IntegerField( null=True, verbose_name=_("Position") )
|
position = models.IntegerField( null=True, verbose_name=_("Position") )
|
||||||
|
|
||||||
|
public_description = models.TextField( blank=True, verbose_name=_("public_description") )
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def isDeepBrass(self):
|
def isDeepBrass(self):
|
||||||
return self.instrument == 'TRB' or self.instrument == "EUPH" or self.instrument == "TUBA" or self.instrument == "HRN"
|
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):
|
def isHighBrass(self):
|
||||||
return self.instrument == 'TR'
|
return self.instrument == 'TR'
|
||||||
|
|
||||||
public_description = models.TextField( blank=True, verbose_name=_("public_description") )
|
|
||||||
|
|
||||||
def __unicode__( self ):
|
def __unicode__( self ):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
|
@ -18,19 +18,18 @@
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h3>{{user.first_name}} {{user.last_name}}</h3>
|
<h3>{{musician.user.first_name}} {{musician.user.last_name}}</h3>
|
||||||
<div class="span6">
|
<div class="span6">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form }}
|
{{ form }}
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" class="btn btn-primary" value="Abschicken"></input>
|
<input type="submit" class="btn btn-primary" value="Speichern"></input>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="span6">
|
<div class="span6">
|
||||||
<img src="{{MEDIA_URL}}/user_images/{{user.username}}.png"></img>
|
<img src="{{MEDIA_URL}}/{{musician.image}}"></img>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -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)
|
|
|
@ -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<username>[\w]+)$$', musicians.views.user_edit ),
|
||||||
|
)
|
||||||
|
|
|
@ -36,15 +36,19 @@ class UserEditForm( forms.ModelForm ):
|
||||||
def save(self):
|
def save(self):
|
||||||
if self.is_valid():
|
if self.is_valid():
|
||||||
super(UserEditForm,self).save()
|
super(UserEditForm,self).save()
|
||||||
self.instance.user.email = self.cleaned_data['email']
|
self.instance.user.email = self.cleaned_data['email']
|
||||||
self.instance.user.save()
|
self.instance.user.save()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Musician
|
model = Musician
|
||||||
exclude = [ 'user','image', 'instrument' ]
|
exclude = [ 'user','image', 'small_image', 'instrument', 'position', 'public_description' ]
|
||||||
#fields = '__all__'
|
#fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
def own_profile( request ):
|
||||||
|
return user_edit( request, request.user )
|
||||||
|
|
||||||
|
|
||||||
def user_edit( request, username ):
|
def user_edit( request, username ):
|
||||||
musician = get_object_or_404( Musician, user__username=username )
|
musician = get_object_or_404( Musician, user__username=username )
|
||||||
|
|
||||||
|
@ -53,11 +57,11 @@ def user_edit( request, username ):
|
||||||
form.instance = musician
|
form.instance = musician
|
||||||
if form.is_valid(): # All validation rules pass
|
if form.is_valid(): # All validation rules pass
|
||||||
form.save()
|
form.save()
|
||||||
return HttpResponseRedirect('/musicians/' + username) # Redirect after POST
|
return HttpResponseRedirect('/') # Redirect after POST
|
||||||
else:
|
else:
|
||||||
form = UserEditForm( instance= musician )
|
form = UserEditForm( instance= musician )
|
||||||
|
|
||||||
return render(request, 'musicians/musician_edit.html', { 'form': form, } )
|
return render(request, 'musicians/musician_edit.html', { 'form': form, 'musician': musician } )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,21 +103,20 @@ $.ajaxSetup({
|
||||||
<div class="nav-collapse collapse">
|
<div class="nav-collapse collapse">
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
{% block menu_contents %}
|
{% block menu_contents %}
|
||||||
|
|
||||||
<li><a href="/">HOME</a></li>
|
<li><a href="/">HOME</a></li>
|
||||||
|
<li><a href="/events"> Termine</a></li>
|
||||||
|
<li><a href="/messages">Forum</a></li>
|
||||||
|
<li><a href="/musicians">Adressbuch</a></li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
{{user.username|capfirst}}
|
{{user.username|capfirst}}
|
||||||
<b class="caret"></b>
|
<b class="caret"></b>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="/events"> Termine</a></li>
|
<li><a href="/musicians/profile">Eigenes Profil</a></li>
|
||||||
<li><a href="/messages">Forum</a></li>
|
|
||||||
<li><a href="/logout"> Logout</a></li>
|
<li><a href="/logout"> Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue