Bugfixes, Daten umgezogen

This commit is contained in:
Martin Bauer
2013-10-15 21:51:05 +02:00
parent 175df72a21
commit cd635aff9b
31 changed files with 71 additions and 54 deletions

View File

@@ -100,8 +100,10 @@ class EventParticipation( models.Model ):
@staticmethod
def members():
perm = Permission.objects.get( codename='member' )
return User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct()
perm = Permission.objects.get( codename='member' )
f = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct()
return f.order_by('musician__position')
@staticmethod
def get_or_create( user , event ):

View File

@@ -17,17 +17,25 @@
{% addtoblock "css" %}
<style>
button.eventButton {
width: 55px;
width: 42px;
}
span.eventButton {
height: 16px;
width: 45px;
width: 32px;
text-align: center;
}
.eventButton i {
margin-right:2px;
}
.with_comment {
font-style: italic;
}
.usernameHeader {
font-size:11px;
text-align: center;
}
</style>
{% endaddtoblock %}
@@ -125,7 +133,7 @@
<th> Termin </th>
<th> Datum </th>
{% for name in usernames %}
<th> {{ name|capfirst }} </th>
<th class='usernameHeader'> {{ name|capfirst }} </th>
{% endfor %}
<th> </th>
@@ -146,18 +154,15 @@
<td class="center userEventTableData" data-username="{{p.user.username}}" data-event="{{event.pk}}">
{% if p.status == "Yes" %}
<button class="btn btn-mini btn-success eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment %} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">Ja</span>
<span class="text {% if p.comment %}with_comment{% endif %}">Ja</span>
</button>
{% elif p.status == "No" %}
<button class="btn btn-mini btn-danger eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment%} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">Nein</span>
<span class="text {% if p.comment %}with_comment{% endif %}">Nein</span>
</button>
{% else %}
<button class="btn btn-mini btn-warning eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment %} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">?</span>
<span class="text {% if p.comment %}with_comment{% endif %}">?</span>
</button>
{% endif %}
</td>
@@ -165,18 +170,15 @@
<td class="center userEventTableData" data-username="{{p.user.username}}" data-event="{{event.pk}}">
{% if p.status == "Yes" %}
<span class="badge badge-success eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment %} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">Ja</span>
<span class="text {% if p.comment %}with_comment{% endif %}">Ja</span>
</span>
{% elif p.status == "No" %}
<span class="badge badge-important eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment%} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">Nein</span>
<span class="text {% if p.comment %}with_comment{% endif %}">Nein</span>
</span>
{% else %}
<span class="badge badge-warning eventButton" title="{{p.comment}}" data-status="{{p.status}}">
{% if p.comment %} <i class="icon-comment icon-white"></i> {% endif %}
<span class="text">?</span>
<span class="text {% if p.comment %}with_comment{% endif %}">?</span>
</span>
{% endif %}
</td>
@@ -185,17 +187,18 @@
{% endfor %}
<td>
<a class="btn btn-mini btn-inverse deleteButton" data-pk="{{event.pk}}"><i class="icon-trash icon-white"></i> Löschen </a>
<a class="btn btn-mini btn-inverse deleteButton" data-pk="{{event.pk}}"><i class="icon-trash icon-white"></i> </a>
</td>
</tr>
{% endfor %}
{% if perms.eventplanner.admin %}
<tr>
<td class="center"> <a href="add">Termin hinzufügen...</a> </td>
<td class="center" colspan="80"> <a href="add">Termin hinzufügen...</a> </td>
<tr>
{% endif %}</form>
{% endif %}
</form>
</tbody>
</table>

View File

@@ -8,9 +8,9 @@ urlpatterns = patterns('',
url(r'^$', eventplanning ),
url(r'^grid$', events_grid ),
url(r'^planning$', eventplanning ),
url(r'^(?P<pk>\d+)$', permission_required('eventmanager.events.edit')( EventUpdate.as_view() ) ),
url(r'^add$', permission_required('eventmanager.events.edit')( EventCreate.as_view() ) ),
url(r'^(?P<pk>\d+)/delete$', permission_required('eventmanager.events.edit')( deleteEvent ) ),
url(r'^(?P<pk>\d+)$', permission_required('eventplanner.change_event')( EventUpdate.as_view() ) ),
url(r'^add$', permission_required('eventplanner.add_event')( EventCreate.as_view() ) ),
url(r'^(?P<pk>\d+)/delete$', permission_required('eventplanner.delete_event')( deleteEvent ) ),
url(r'^api/', event_api, name="event_api" ),
url(r'^api/(\w+)/$', event_api, name="event_api_per_user" ),
url(r'^api/(\w+)/(\d+)$', event_api, name="event_api_per_user_event"),

View File

@@ -44,17 +44,15 @@ def event_api( request, username = None, eventId = None ):
serializer = ParticipationSerializer ( participationQs, data = request.DATA, many=True )
if serializer.is_valid():
for serializedObject in serializer.object:
if not EventParticipation.isMember( request.user ):
if not ( EventParticipation.isMember( request.user ) or EventParticipation.isAdmin( request.user ) ):
return Response( status = status.HTTP_403_FORBIDDEN )
if serializedObject.user != request.user:
if not EventParticipation.isAdmin( request.user ):
return Response( status = status.HTTP_403_FORBIDDEN )
print serializer.data
serializer.save()
return Response( serializer.data )
else:
print "In Bad request" + str(serializer.errors)
return Response( status = status.HTTP_400_BAD_REQUEST )
@@ -67,7 +65,6 @@ def eventplanning( request ):
"""
# non-members see the grid - but cannot edit anything
if not EventParticipation.isMember( request.user ):
print "Not a member"
return events_grid(request)
# All events in the future sorted by date