This commit is contained in:
Élie Bouttier 2014-08-20 17:33:15 -07:00
parent fe297c8a7d
commit e75383bb2f
4 changed files with 25 additions and 17 deletions

View file

@ -16,7 +16,7 @@ from colorful.fields import RGBColorField
import json import json
from issue.templatetags.issue_tags import same_milestone, same_label, label_style, labeled from issue.templatetags.issue_tags import *
class User(auth.models.User): class User(auth.models.User):
@ -342,8 +342,10 @@ class Event(models.Model):
action = 'removed' action = 'removed'
description = '%s the <a href="%s" class="label" ' \ description = '%s the <a href="%s" class="label" ' \
'style="%s">%s</a> label' \ 'style="%s">%s</a> label' \
% (action, same_label(label), label_style(label), label) % (action, same_label(label),
elif self.code == Event.SET_MILESTONE or self.code == Event.UNSET_MILESTONE: label_style(label), label)
elif self.code == Event.SET_MILESTONE \
or self.code == Event.UNSET_MILESTONE:
milestone = Milestone(name=args['milestone'], milestone = Milestone(name=args['milestone'],
project=self.issue.project) project=self.issue.project)
if self.code == Event.SET_MILESTONE: if self.code == Event.SET_MILESTONE:

View file

@ -32,8 +32,8 @@ def notify_new_issue(issue):
c = { c = {
'description': issue.description, 'description': issue.description,
'uri': settings.BASE_URL \ 'uri': settings.BASE_URL + reverse('show-issue',
+ reverse('show-issue', args=[project.name, issue.id]), args=[project.name, issue.id]),
} }
message = render_to_string('emails/new_issue.html', c) message = render_to_string('emails/new_issue.html', c)
@ -85,8 +85,8 @@ def notify_event(event, template):
c = { c = {
'comment': event.additionnal_section, 'comment': event.additionnal_section,
'uri': settings.BASE_URL \ 'uri': settings.BASE_URL + reverse('show-issue',
+ reverse('show-issue', args=[project.name, issue.id]), args=[project.name, issue.id]),
} }
message = render_to_string('emails/%s.html' % template, c) message = render_to_string('emails/%s.html' % template, c)

View file

@ -14,6 +14,7 @@ def boolean(value):
return mark_safe('<span class="glyphicon glyphicon-' return mark_safe('<span class="glyphicon glyphicon-'
+ glyph + '" style="vertical-align: middle;"></span>') + glyph + '" style="vertical-align: middle;"></span>')
@register.filter @register.filter
def first_few(items, arg='item', max_items=5): def first_few(items, arg='item', max_items=5):
if items.exists(): if items.exists():

View file

@ -938,11 +938,13 @@ def project_subscribe(request, project):
user = User.objects.get(username=request.user.username) user = User.objects.get(username=request.user.username)
if project.subscribers.filter(username=user.username).exists(): if project.subscribers.filter(username=user.username).exists():
messages.warning(request, 'You are already subscribed to this project.') messages.warning(request,
'You are already subscribed to this project.')
else: else:
project.subscribers.add(user) project.subscribers.add(user)
project.save() project.save()
messages.success(request, 'You have been subscribed to this project successfully.') messages.success(request,
'You have been subscribed to this project successfully.')
next = request.GET.get('next') next = request.GET.get('next')
if next: if next:
@ -959,7 +961,8 @@ def project_unsubscribe(request, project):
if project.subscribers.filter(username=user.username).exists(): if project.subscribers.filter(username=user.username).exists():
project.subscribers.remove(user) project.subscribers.remove(user)
project.save() project.save()
messages.success(request, 'You will not receive any notifications for this project anymore.') messages.success(request, 'You will not receive any notifications '
'for this project anymore.')
else: else:
messages.warning(request, 'You are not subscribed to this project.') messages.warning(request, 'You are not subscribed to this project.')
@ -981,7 +984,8 @@ def issue_subscribe(request, project, issue):
else: else:
issue.subscribers.add(user) issue.subscribers.add(user)
issue.save() issue.save()
messages.success(request, 'You have been subscribed to this issue successfully.') messages.success(request,
'You have been subscribed to this issue successfully.')
return redirect('show-issue', project.name, issue.id) return redirect('show-issue', project.name, issue.id)
@ -995,7 +999,8 @@ def issue_unsubscribe(request, project, issue):
if issue.subscribers.filter(username=user.username).exists(): if issue.subscribers.filter(username=user.username).exists():
issue.subscribers.remove(user) issue.subscribers.remove(user)
issue.save() issue.save()
messages.success(request, 'You will not receive any notifications for this issue anymore.') messages.success(request, 'You will not receive any notifications '
'for this issue anymore.')
else: else:
messages.warning(request, 'You are not subscribed to this issue.') messages.warning(request, 'You are not subscribed to this issue.')