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 }}.
{% trans "Source string:" %}
{{ suggestion.source }}
{{ suggestion.get_source }}
{% 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" %}
......@@ -1639,12 +1639,19 @@ class Suggestion(models.Model):
unit.fuzzy = False
unit.save_backend(request, False)
def get_source(self):
Unit.objects.filter(
def get_matching_unit(self):
return Unit.objects.filter(
checksum = self.checksum,
translation__subproject__project = self.project,
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]
......
......@@ -710,12 +710,18 @@ def translate(request, project, subproject, lang):
pos,
search_url
))
Suggestion.objects.create(
# Create the suggestion
sug = Suggestion.objects.create(
target = join_plural(form.cleaned_data['target']),
checksum = unit.checksum,
language = unit.translation.language,
project = unit.translation.subproject.project,
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
if profile is not None:
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