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

@ -18,7 +18,7 @@ def notify_new_issue(issue):
else: else:
return return
subject = "[%s] %s" %(project, issue.title) subject = "[%s] %s" % (project, issue.title)
data = [] data = []
for dest in dests: for dest in dests:
@ -32,14 +32,14 @@ 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)
data += [(subject, message, data += [(subject, message,
"%s <%s>" %(issue.author.username, from_addr), [dest_addr])] "%s <%s>" % (issue.author.username, from_addr), [dest_addr])]
send_mass_mail(tuple(data)) send_mass_mail(tuple(data))
@ -70,7 +70,7 @@ def notify_event(event, template):
else: else:
return return
subject = "Re: [%s] %s" %(project, issue.title) subject = "Re: [%s] %s" % (project, issue.title)
data = [] data = []
@ -85,13 +85,13 @@ 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)
data += [(subject, message, data += [(subject, message,
'%s <%s>' %(event.author.username, from_addr), [dest_addr])] '%s <%s>' % (event.author.username, from_addr), [dest_addr])]
send_mass_mail(tuple(data)) send_mass_mail(tuple(data))

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():
@ -21,7 +22,7 @@ def first_few(items, arg='item', max_items=5):
return ', '.join(map(lambda x: x.__str__(), items.all())) return ', '.join(map(lambda x: x.__str__(), items.all()))
else: else:
r = ', '.join(map(lambda x: x.__str__(), r = ', '.join(map(lambda x: x.__str__(),
items.all()[0:max_items-1])) items.all()[0:max_items - 1]))
plural = 's' if items.count() > max_items else '' plural = 's' if items.count() > max_items else ''
r += ', ... (%s other%s)' \ r += ', ... (%s other%s)' \
% (items.count() - max_items + 1, plural) % (items.count() - max_items + 1, plural)

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.')