Skip to content

Commit

Permalink
build urls for related objects in notification template
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Glatthard committed Aug 7, 2015
1 parent 7d6c63b commit 778d61a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions ipynbsrv/api/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class NestedNotificationSerializer(serializers.ModelSerializer):
notification_type = serializers.ChoiceField(choices=Notification.NOTIFICATION_TYPES, default='miscellaneous')
sender = UserSerializer(many=False)
url_slug = serializers.CharField(source='get_related_object_url', read_only=True)
has_related_object = serializers.BooleanField(read_only=True)

class Meta:
model = Notification
Expand Down
2 changes: 1 addition & 1 deletion ipynbsrv/web/templates/web/notifications/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Notifications</h1>
<td>{{ n.date | date:"d.m.Y, H:i" }}</td>
<td>{{ n.notification.sender.username }}</td>
<td>{{ n.notification.message }}</td>
<td>{% if n.notification.url_slug %}<a href="{{ n.notification.url_slug }}">{{ n.notification.notification_type }}</a>{% else %}{{ n.notification.notification_type }}{% endif %}</td>
<td>{% if n.notification.has_related_object %}<a href="{% if n.notification.notification_type == 'container'%}{% url 'containers' %}{% elif n.notification.notification_type == 'container_image'%}{% url 'images' %}{% elif n.notification.notification_type == 'group' %}{% url 'group_manage' n.notification.group %}{% elif n.notification.notification_type == 'share' %}{% url 'share_manage' n.notification.share %}{% endif %}">{{ n.notification.notification_type }}</a>{% else %}{{ n.notification.notification_type }}{% endif %}</td>
<td>{{ n.read }}</td>
<td>
<form action="{% url 'notification_mark_as_read' %}" method="POST" role="form" class="form-action">
Expand Down

0 comments on commit 778d61a

Please sign in to comment.