[damned-lies] Allow vertimus comments to be sent (or not) to the mailing list (Fixes #650566)
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Allow vertimus comments to be sent (or not) to the mailing list (Fixes #650566)
- Date: Wed, 7 Mar 2012 17:32:16 +0000 (UTC)
commit 2c4fee86e64e222468b51dd662124fb354ff88cf
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Mar 7 18:31:39 2012 +0100
Allow vertimus comments to be sent (or not) to the mailing list (Fixes #650566)
media/css/main.css | 4 -
stats/templatetags/stats_extras.py | 2 +-
templates/vertimus/vertimus_detail.html | 20 +++-
vertimus/forms.py | 10 ++-
vertimus/models.py | 178 ++++++++++++++-----------------
vertimus/tests/__init__.py | 86 ++++++++-------
vertimus/views.py | 10 +-
7 files changed, 158 insertions(+), 152 deletions(-)
---
diff --git a/media/css/main.css b/media/css/main.css
index 7b8ca48..6db8037 100644
--- a/media/css/main.css
+++ b/media/css/main.css
@@ -308,10 +308,6 @@ p#show, p#hide {
color: #666666;
}
-.djform td {
- font-size: 10px;
- color: #999;
-}
.djform th {
vertical-align: top;
}
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index a7480d3..4cf0c6a 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -146,7 +146,7 @@ def is_video(fig):
def as_tr(field):
help_html = u''
if field.help_text:
- help_html = u'<br /><span class="helptext">%s</span>' % field.help_text
+ help_html = u'<br><span class="help">%s</span>' % field.help_text
help_link = u''
# This is a custom attribute possibly set in forms.py
if hasattr(field.field, 'help_link'):
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index c47b4b5..365a309 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -11,6 +11,10 @@
<script type="text/javascript">
$(document).ready(function() {
$("#id_comment").growfield();
+ $("#id_send_to_ml").attr('checked', send_mail_defaults[$("#id_action").val()]);
+ $("#id_action").change(function () {
+ $("#id_send_to_ml").attr('checked', send_mail_defaults[$(this).val()]);
+ });
});
</script>
{% endblock %}
@@ -203,10 +207,20 @@ $(document).ready(function() {
<form enctype="multipart/form-data"
action="{% url 'vertimus_by_stats_id' stats.id language.id %}"
method="POST">
- <table class="djform">
- {% for field in action_form %}
- {{ field|as_tr }}
+ <script type="text/javascript">
+ var send_mail_defaults = Array();
+ {% for action in action_form.actions %}
+ {% if action.name %}send_mail_defaults['{{ action.name }}'] = {{ action.send_mail_to_ml|lower }};{% endif %}
{% endfor %}
+ </script>
+
+ <table class="djform">
+ {{ action_form.action|as_tr }}
+ {{ action_form.comment|as_tr }}
+ {{ action_form.file|as_tr }}
+ {% if action_form.send_to_ml %}
+ <tr><td></td><td>{{ action_form.send_to_ml }} <label for="id_send_to_ml">{{ action_form.send_to_ml.label }}</label></td></tr>
+ {% endif %}
<tr>
<td></td>
<td><input type="submit" value="{% trans "Submit" %}"></td>
diff --git a/vertimus/forms.py b/vertimus/forms.py
index d3648e3..1dffde5 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -47,11 +47,17 @@ class ActionForm(forms.Form):
widget=forms.Textarea(attrs={'rows':8, 'cols':70}))
file = forms.FileField(label=_("File"), required=False,
help_text=_("Upload a .po, .gz, .bz2 or .png file"))
+ send_to_ml = forms.BooleanField(label=_("Send message to the team mailing list"), required=False)
- def __init__(self, available_actions, *args, **kwargs):
+ def __init__(self, actions, has_mailing_list, *args, **kwargs):
super(ActionForm, self).__init__(*args, **kwargs)
- self.fields['action'].choices = available_actions
+ self.actions = actions
+ self.fields['action'].choices = [
+ (act.name, act.description) for act in actions
+ ]
self.fields['action'].help_link = reverse('help', args=['vertimus_workflow'])
+ if not has_mailing_list:
+ del self.fields['send_to_ml']
def clean_file(self):
data = self.cleaned_data['file']
diff --git a/vertimus/models.py b/vertimus/models.py
index 1cd2b10..50b0c92 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2008-2009 StÃphane Raimbault <stephane raimbault gmail com>
-# Copyright (c) 2011 Claude Paroz <claude 2xlibre net>
+# Copyright (c) 2011-2012 Claude Paroz <claude 2xlibre net>
#
# This file is part of Damned Lies.
#
@@ -30,7 +30,7 @@ from django.db import models
from django.db.models import Max
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
-from django.utils.translation import get_language, activate, ugettext, ugettext_lazy as _
+from django.utils.translation import get_language, activate, ugettext, ugettext_noop, ugettext_lazy as _
from stats.models import Branch, Domain, Statistics, PoFile
from stats.signals import pot_has_changed
@@ -322,6 +322,9 @@ class ActionAbstract(models.Model):
file_is_required = False
file_is_prohibited = False
+ target_state = None
+ send_mail_to_ml = False
+
class Meta:
abstract = True
@@ -394,24 +397,26 @@ class Action(ActionAbstract):
self.created = datetime.today()
super(Action, self).save(*args, **kwargs)
- def apply_on(self, state):
+ def apply_on(self, state, send_to_ml):
if not self in state.get_available_actions(self.person):
raise Exception('Not allowed')
self.state_db = state
if self.file:
self.file.save(self.file.name, self.file, save=False)
self.save()
- if not isinstance(self, ActionWC):
+ if self.target_state is not None:
# All actions change state except Writing a comment
self.state_db.change_state(self.target_state, self.person)
- if self.target_state == StateCommitted:
- self.send_mail_new_state(state, (state.language.team.mailing_list,))
- # Committed is the last state of the workflow, archive actions
- arch_action = self.new_by_name('AA', person=self.person)
- arch_action.apply_on(self.state_db)
else:
# Force updated state date to be updated
self.state_db.save()
+ if send_to_ml:
+ self.send_mail_new_state(state, (state.language.team.mailing_list,))
+
+ if self.target_state == StateCommitted:
+ # Committed is the last state of the workflow, archive actions
+ arch_action = self.new_by_name('AA', person=self.person)
+ arch_action.apply_on(self.state_db, False)
def get_previous_action_with_po(self):
"""
@@ -449,40 +454,45 @@ class Action(ActionAbstract):
os.remove(temp_path)
self.merged_file.update_stats()
- def send_mail_new_state(self, state, recipient_list):
+ def send_mail_new_state(self, state, recipient_list, msg=None):
+ """ msg is an optional untranslated string, which will be translated after
+ state.language will be activated
+ """
# Remove None and empty string items from the list
recipient_list = filter(lambda x: x and x is not None, recipient_list)
- if recipient_list:
- current_lang = get_language()
- activate(state.language.locale)
- current_site = Site.objects.get_current()
- url = "http://%s%s" % (current_site.domain, urlresolvers.reverse(
- 'vertimus_by_names',
- args = (
- state.branch.module.name,
- state.branch.name,
- state.domain.name,
- state.language.locale)))
- subject = state.branch.module.name + u' - ' + state.branch.name
- message = _(u"""Hello,
-
-The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now '%(new_state)s'.
-%(url)s
-
-""") % {
- 'module': state.branch.module.name,
- 'branch': state.branch.name,
- 'domain': state.domain.name,
- 'language': state.language.get_name(),
- 'new_state': state.description,
- 'url': url
- }
- message += self.comment or ugettext("Without comment")
- message += "\n\n" + self.person.name
- message += "\n--\n" + _(u"This is an automated message sent from %s.") % current_site.domain
- mail.send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list)
- activate(current_lang)
+ if not recipient_list:
+ return
+
+ current_lang = get_language()
+ activate(state.language.locale)
+ if not msg:
+ msg = ugettext(u"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now '%(new_state)s'.")
+ else:
+ msg = ugettext(msg)
+ current_site = Site.objects.get_current()
+ url = "http://%s%s" % (current_site.domain, urlresolvers.reverse(
+ 'vertimus_by_names',
+ args = (
+ state.branch.module.name,
+ state.branch.name,
+ state.domain.name,
+ state.language.locale)))
+ subject = state.branch.module.name + u' - ' + state.branch.name
+ message = ugettext(u"Hello,") + u"\n\n" + msg + u"\n%(url)s\n\n"
+ message = message % {
+ 'module': state.branch.module.name,
+ 'branch': state.branch.name,
+ 'domain': state.domain.name,
+ 'language': state.language.get_name(),
+ 'new_state': state.description,
+ 'url': url
+ }
+ message += self.comment or ugettext("Without comment")
+ message += "\n\n" + self.person.name
+ message += "\n--\n" + ugettext(u"This is an automated message sent from %s.") % current_site.domain
+ mail.send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list)
+ activate(current_lang)
def generate_archive_filename(instance, original_filename):
@@ -515,46 +525,22 @@ class ActionWC(Action):
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionWC, self).apply_on(state)
-
- # Send an email to all translators of the page
- translator_emails = set()
- for d in Person.objects.filter(action__state_db=state).values('email'):
- translator_emails.add(d['email'])
-
- # Remove None items from the list
- translator_emails = filter(lambda x: x is not None, translator_emails)
-
- if translator_emails:
- current_lang = get_language()
- activate(state.language.locale)
- current_site = Site.objects.get_current()
- url = "http://%s%s" % (current_site.domain, urlresolvers.reverse(
- 'vertimus_by_names',
- args = (
- state.branch.module.name,
- state.branch.name,
- state.domain.name,
- state.language.locale)))
- subject = state.branch.module.name + u' - ' + state.branch.name
- message = _(u"""Hello,
-
-A new comment has been left on %(module)s - %(branch)s - %(domain)s (%(language)s).
-%(url)s
-
-""") % {
- 'module': state.branch.module.name,
- 'branch': state.branch.name,
- 'domain': state.domain.name,
- 'language': state.language.get_name(),
- 'url': url
- }
- message += self.comment or ugettext("Without comment")
- message += "\n\n" + self.person.name
- message += "\n--\n" + _(u"This is an automated message sent from %s.") % current_site.domain
- mail.send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, translator_emails)
- activate(current_lang)
+ def apply_on(self, state, send_to_ml):
+ super(ActionWC, self).apply_on(state, False)
+
+ if send_to_ml:
+ recipients = (state.language.team.mailing_list,)
+ else:
+ # Send an email to all translators of the page
+ translator_emails = set()
+ for d in Person.objects.filter(action__state_db=state).values('email'):
+ translator_emails.add(d['email'])
+ # Remove None items from the list
+ recipients = filter(lambda x: x is not None, translator_emails)
+
+ self.send_mail_new_state(state, recipients,
+ msg=ugettext_noop(u"A new comment has been posted on %(module)s - %(branch)s - %(domain)s (%(language)s)."))
+
class ActionRT(Action):
name = 'RT'
@@ -568,14 +554,11 @@ class ActionUT(Action):
name = 'UT'
target_state = StateTranslated
file_is_required = True
+ send_mail_to_ml = True
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionUT, self).apply_on(state)
- self.send_mail_new_state(state, (state.language.team.mailing_list,))
-
class ActionRP(Action):
name = 'RP'
target_state = StateProofreading
@@ -588,14 +571,11 @@ class ActionUP(Action):
name = 'UP'
target_state = StateProofread
file_is_required = True
+ send_mail_to_ml = True
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionUP, self).apply_on(state)
- self.send_mail_new_state(state, (state.language.team.mailing_list,))
-
class ActionTC(Action):
name = 'TC'
target_state = StateToCommit
@@ -603,8 +583,8 @@ class ActionTC(Action):
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionTC, self).apply_on(state)
+ def apply_on(self, state, send_to_ml):
+ super(ActionTC, self).apply_on(state, send_to_ml)
# Send an email to all committers of the team
committers = [c.email for c in state.language.team.get_committers()]
self.send_mail_new_state(state, committers)
@@ -617,7 +597,7 @@ class ActionCI(Action):
class Meta:
proxy = True
- def apply_on(self, state):
+ def apply_on(self, state, send_to_ml):
action_with_po = self.get_previous_action_with_po()
try:
state.branch.commit_po(action_with_po.file.path, state.domain, state.language, self.person)
@@ -626,7 +606,7 @@ class ActionCI(Action):
# FIXME: somewhere the error should be catched and handled properly
raise Exception(_("The commit failed. The error was: '%s'") % sys.exc_info()[1])
- super(ActionCI, self).apply_on(state) # Mail sent in super
+ super(ActionCI, self).apply_on(state, send_to_ml) # Mail sent in super
class ActionRC(Action):
name = 'RC'
@@ -639,6 +619,7 @@ class ActionRC(Action):
class ActionIC(Action):
name = 'IC'
target_state = StateCommitted
+ send_mail_to_ml = True
class Meta:
proxy = True
@@ -647,14 +628,11 @@ class ActionTR(Action):
name = 'TR'
target_state = StateToReview
arg_is_required = True
+ send_mail_to_ml = True
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionTR, self).apply_on(state)
- self.send_mail_new_state(state, (state.language.team.mailing_list,))
-
class ActionAA(Action):
name = 'AA'
target_state = StateNone
@@ -662,8 +640,8 @@ class ActionAA(Action):
class Meta:
proxy = True
- def apply_on(self, state):
- super(ActionAA, self).apply_on(state)
+ def apply_on(self, state, send_to_ml):
+ super(ActionAA, self).apply_on(state, send_to_ml)
all_actions = Action.objects.filter(state_db=state).order_by('id').all()
sequence = None
@@ -700,7 +678,7 @@ class ActionUNDO(Action):
class Meta:
proxy = True
- def apply_on(self, state):
+ def apply_on(self, state, send_to_ml):
self.state_db = state
self.save()
@@ -719,6 +697,8 @@ class ActionUNDO(Action):
state.change_state(action.target_state, action.person)
return
state.change_state(StateNone)
+ if send_to_ml:
+ self.send_mail_new_state(state, (state.language.team.mailing_list,))
class ActionSeparator(object):
""" Fake action to add a separator in action menu """
diff --git a/vertimus/tests/__init__.py b/vertimus/tests/__init__.py
index 363b97e..866c2cb 100644
--- a/vertimus/tests/__init__.py
+++ b/vertimus/tests/__init__.py
@@ -195,18 +195,28 @@ class VertimusTest(TeamsAndRolesTests):
prev_updated = state.updated
action = Action.new_by_name('WC', person=self.pt, comment="Hi!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [self.pt.email])
# Test that submitting a comment without text generates a validation error
- form = ActionForm([('WC', u'Write a comment')], QueryDict('action=WC&comment='))
+ form = ActionForm([ActionWC()], True, QueryDict('action=WC&comment='))
self.assertTrue("A comment is needed" in str(form.errors))
self.assertNotEqual(state.updated, prev_updated)
+ # Test send comment to mailing list
+ mail.outbox = []
+ action = Action.new_by_name('WC', person=self.pt, comment="Hi again!")
+ action.apply_on(state, True)
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [self.l.team.mailing_list])
+ self.assertIn(u"Hi again!", mail.outbox[0].body)
+
def test_action_rt(self):
state = StateNone(branch=self.b, domain=self.d, language=self.l)
state.save()
action = Action.new_by_name('RT', person=self.pt, comment="Reserved!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertTrue(isinstance(state, StateTranslating))
@test_scratchdir
@@ -222,7 +232,7 @@ class VertimusTest(TeamsAndRolesTests):
test_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "valid_po.po"), 'r')
action = Action.new_by_name('UT', person=self.pt, comment="Done by translator.", file=File(test_file))
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEqual(action.file.url, '/media/upload/gedit-gnome-2-24-po-fr-%d.po' % state.id)
self.assertEqual(action.merged_file.url(), '/media/upload/gedit-gnome-2-24-po-fr-%d.merged.po' % state.id)
self.files_to_clean.extend([action.file.path, action.merged_file.path])
@@ -242,7 +252,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('RP', person=self.pr, comment="Reserved by a reviewer!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertTrue(isinstance(state, StateProofreading))
def test_action_up(self):
@@ -253,7 +263,7 @@ class VertimusTest(TeamsAndRolesTests):
test_file.name = 'mytestfile.po'
action = Action.new_by_name('UP', person=self.pr, comment="Done.", file=test_file)
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.files_to_clean.append(action.file.path)
self.assertTrue(isinstance(state, StateProofread))
@@ -262,7 +272,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('TC', person=self.pr, comment="Ready!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertTrue(isinstance(state, StateToCommit))
def test_action_rc(self):
@@ -270,7 +280,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('RC', person=self.pc, comment="This work is mine!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertTrue(isinstance(state, StateCommitting))
def test_action_ic(self):
@@ -282,7 +292,7 @@ class VertimusTest(TeamsAndRolesTests):
test_file.name = 'mytestfile.po'
action = Action.new_by_name('UP', person=self.pr, comment="Done.", file=test_file)
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEquals(len(mail.outbox), 1) # Mail sent to mailing list
mail.outbox = []
@@ -290,15 +300,15 @@ class VertimusTest(TeamsAndRolesTests):
self.assertTrue(os.access(file_path, os.W_OK))
action = Action.new_by_name('TC', person=self.pc, comment="To commit.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEquals(len(mail.outbox), 1) # Mail sent to committers
mail.outbox = []
action = Action.new_by_name('RC', person=self.pc, comment="Reserved commit.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('IC', person=self.pc, comment="Committed.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
# Mail sent to mailing list
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].recipients(), [self.l.team.mailing_list])
@@ -318,7 +328,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('TR', person=self.pc, comment="Bad work :-/")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertTrue(isinstance(state, StateToReview))
def test_action_aa(self):
@@ -326,7 +336,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('AA', person=self.pc, comment="I don't want to disappear :)")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
state = State.objects.get(branch=self.b, domain=self.d, language=self.l)
self.assertTrue(isinstance(state, StateNone))
@@ -337,38 +347,38 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('RT', person=self.pt, comment="Reserved!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pt, comment="Ooops! I don't want to do that. Sorry.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEqual(state.name, 'None')
action = Action.new_by_name('RT', person=self.pt, comment="Translating")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UT', person=self.pt, comment="Translated")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('RT', person=self.pt, comment="Reserved!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pt, comment="Ooops! I don't want to do that. Sorry.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEqual(state.name, 'Translated')
action = Action.new_by_name('RT', person=self.pt, comment="Translating 1")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pt, comment="Undo 1")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('RT', person=self.pt, comment="Translating 2")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pt, comment="Undo 2")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.assertEqual(state.name, 'Translated')
@@ -378,7 +388,7 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('WC', person=self.pt, comment="Hi!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
self.m.delete()
self.assertEqual(Action.objects.all().count(), 0)
@@ -408,26 +418,26 @@ class VertimusTest(TeamsAndRolesTests):
# Test a non valid po file
post_content = QueryDict('action=WC&comment=Test1')
post_file = MultiValueDict({'file': [SimpleUploadedFile('filename.po', 'Not valid po file content')]})
- form = ActionForm([('WC', u'Write a comment')], post_content, post_file)
+ form = ActionForm([ActionWC()], True, post_content, post_file)
- self.assert_('file' in form.errors)
+ self.assertTrue('file' in form.errors)
# Test a valid po file
f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "valid_po.po"), 'r')
post_file = MultiValueDict({'file': [File(f)]})
- form = ActionForm([('WC', u'Write a comment')], post_content, post_file)
- self.assert_(form.is_valid())
+ form = ActionForm([ActionWC()], True, post_content, post_file)
+ self.assertTrue(form.is_valid())
# Test form without file
- form = ActionForm([('WC', u'Write a comment')], post_content)
- self.assert_(form.is_valid())
+ form = ActionForm([ActionWC()], True, post_content)
+ self.assertTrue(form.is_valid())
def test_feeds(self):
state = StateNone(branch=self.b, domain=self.d, language=self.l)
state.save()
action = Action.new_by_name('RT', person=self.pt, comment="Translating")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
response = self.client.get(reverse('lang_feed', args=[self.l.locale]))
self.assertContains(response,
@@ -456,22 +466,22 @@ class VertimusTest(TeamsAndRolesTests):
state.save()
action = Action.new_by_name('RT', person=self.pr, comment="Reserved!")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pr, comment="Ooops! I don't want to do that. Sorry.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('RT', person=self.pr, comment="Translating")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UT', person=self.pr, comment="Translated")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('RP', person=self.pr, comment="Proofreading")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
action = Action.new_by_name('UNDO', person=self.pr, comment="Ooops! I don't want to do that. Sorry.")
- action.apply_on(state)
+ action.apply_on(state, action.send_mail_to_ml)
actions_db = Action.objects.filter(state_db__id=state.id).exclude(name='WC').order_by('-id')
diff --git a/vertimus/views.py b/vertimus/views.py
index 3ab1639..434177d 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -90,10 +90,10 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
# possible to edit an archived workflow
person = request.user.person
- available_actions = [(va.name, va.description)
- for va in state.get_available_actions(person)]
+ available_actions = state.get_available_actions(person)
if request.method == 'POST':
- action_form = ActionForm(available_actions, request.POST, request.FILES)
+ action_form = ActionForm(
+ available_actions, bool(language.team.mailing_list), request.POST, request.FILES)
if action_form.is_valid():
# Process the data in form.cleaned_data
@@ -102,14 +102,14 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
action = Action.new_by_name(action, person=person, comment=comment,
file=request.FILES.get('file', None))
- action.apply_on(state)
+ action.apply_on(state, action_form.cleaned_data.get('send_to_ml'))
return HttpResponseRedirect(
urlresolvers.reverse('vertimus_by_names',
args=(branch.module.name, branch.name, domain.name,
language.locale)))
else:
- action_form = ActionForm(available_actions)
+ action_form = ActionForm(available_actions, bool(language.team.mailing_list))
else:
action_form = None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]