Commit 389efc2a authored by Michal Čihař's avatar Michal Čihař

Implemented notifications for new suggestions (issue #59)

parent 8d2e4a51
...@@ -5,10 +5,14 @@ there is new suggestion evaluate on {{ translation }} at {{ site_title }}. ...@@ -5,10 +5,14 @@ there is new suggestion evaluate on {{ translation }} at {{ site_title }}.
{% trans "Source string:" %} {% trans "Source string:" %}
{{ suggestion.source }} {{ suggestion.get_source }}
{% trans "Translation:" %} {% trans "Translation:" %}
{{ suggestion.get_target }} {{ suggestion.target }}
{% trans "You can review it at:" %}
http://{{ current_site }}{{ suggestion.get_review_url }}
{% endfilter%}{% endautoescape %}{% include "mail/footer.txt" %} {% endfilter%}{% endautoescape %}{% include "mail/footer.txt" %}
...@@ -1639,12 +1639,19 @@ class Suggestion(models.Model): ...@@ -1639,12 +1639,19 @@ class Suggestion(models.Model):
unit.fuzzy = False unit.fuzzy = False
unit.save_backend(request, False) unit.save_backend(request, False)
def get_source(self): def get_matching_unit(self):
Unit.objects.filter( return Unit.objects.filter(
checksum = self.checksum, checksum = self.checksum,
translation__subproject__project = self.project, translation__subproject__project = self.project,
translation__language = self.language, translation__language = self.language,
)[0].source )[0]
def get_source(self):
return self.get_matching_unit().source
def get_review_url(self):
return self.get_matching_unit().get_absolute_url()
CHECK_CHOICES = [(x, CHECKS[x].name) for x in CHECKS] CHECK_CHOICES = [(x, CHECKS[x].name) for x in CHECKS]
......
...@@ -710,12 +710,18 @@ def translate(request, project, subproject, lang): ...@@ -710,12 +710,18 @@ def translate(request, project, subproject, lang):
pos, pos,
search_url search_url
)) ))
Suggestion.objects.create( # Create the suggestion
sug = Suggestion.objects.create(
target = join_plural(form.cleaned_data['target']), target = join_plural(form.cleaned_data['target']),
checksum = unit.checksum, checksum = unit.checksum,
language = unit.translation.language, language = unit.translation.language,
project = unit.translation.subproject.project, project = unit.translation.subproject.project,
user = user) user = user)
# Notify subscribed users
from weblate.accounts.models import Profile
subscriptions = Profile.objects.subscribed_new_suggestion(obj.subproject.project, obj.language)
for subscription in subscriptions:
subscription.notify_new_suggestion(obj, sug)
# Update suggestion stats # Update suggestion stats
if profile is not None: if profile is not None:
profile.suggested += 1 profile.suggested += 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment