def generate_change(self, request, author, change_action): """Create Change entry for saving unit.""" user = request.user if request else author # Notify about new contributor user_changes = Change.objects.filter(translation=self.translation, user=user) if not user_changes.exists(): from weblate.accounts.notifications import notify_new_contributor notify_new_contributor(self, user) # Action type to store if change_action is not None: action = change_action elif self.old_unit.state >= STATE_TRANSLATED: action = Change.ACTION_CHANGE else: action = Change.ACTION_NEW kwargs = {} # Should we store history of edits? if self.translation.component.save_history: kwargs['target'] = self.target kwargs['old'] = self.old_unit.target # Create change object Change.objects.create(unit=self, action=action, user=user, author=author, **kwargs)
def generate_change(self, request, author, oldunit, change_action): """Create Change entry for saving unit.""" # Notify about new contributor user_changes = Change.objects.filter( translation=self.translation, user=request.user ) if not user_changes.exists(): notify_new_contributor(self, request.user) # Action type to store if change_action is not None: action = change_action elif oldunit.translated: action = Change.ACTION_CHANGE else: action = Change.ACTION_NEW kwargs = {} # Should we store history of edits? if self.translation.subproject.save_history: kwargs['target'] = self.target kwargs['old'] = self.old_unit.target # Create change object Change.objects.create( unit=self, translation=self.translation, action=action, user=request.user, author=author, **kwargs )
def generate_change(self, request, author, change_action): """Create Change entry for saving unit.""" # Notify about new contributor user_changes = Change.objects.filter( translation=self.translation, user=request.user ) if not user_changes.exists(): from weblate.accounts.notifications import notify_new_contributor notify_new_contributor(self, request.user) # Action type to store if change_action is not None: action = change_action elif self.old_unit.state >= STATE_TRANSLATED: action = Change.ACTION_CHANGE else: action = Change.ACTION_NEW kwargs = {} # Should we store history of edits? if self.translation.component.save_history: kwargs['target'] = self.target kwargs['old'] = self.old_unit.target # Create change object Change.objects.create( unit=self, action=action, user=request.user, author=author, **kwargs )
def notify_change(change_id): from weblate.trans.models import Change from weblate.accounts.notifications import ( notify_merge_failure, notify_parse_error, notify_new_string, notify_new_contributor, notify_new_suggestion, notify_new_comment, notify_new_translation, notify_new_language, ) change = Change.objects.get(pk=change_id) if change.action in (Change.ACTION_FAILED_MERGE, Change.ACTION_FAILED_REBASE): notify_merge_failure(change) elif change.action == Change.ACTION_PARSE_ERROR: notify_parse_error(change) elif change.action == Change.ACTION_NEW_STRING: notify_new_string(change) elif change.action == Change.ACTION_NEW_CONTRIBUTOR: notify_new_contributor(change) elif change.action == Change.ACTION_SUGGESTION: notify_new_suggestion(change) elif change.action == Change.ACTION_COMMENT: notify_new_comment(change) elif change.action in Change.ACTIONS_CONTENT: notify_new_translation(change) elif change.action in (Change.ACTION_ADDED_LANGUAGE, Change.ACTION_REQUESTED_LANGUAGE): notify_new_language(change)
def test_notify_new_contributor(self): unit = self.get_unit() notify_new_contributor(unit, self.second_user()) # Check mail self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, '[Weblate] New contributor in Test/Test - Czech')
def test_notify_new_contributor(self): unit = self.get_unit() notify_new_contributor( unit, self.second_user() ) # Check mail self.assertEqual(len(mail.outbox), 1) self.assertEqual( mail.outbox[0].subject, '[Weblate] New contributor in Test/Test - Czech' )