def save(self, *args, **kwargs):
        snippet = super().save(*args, **kwargs)

        if (('status' in self.changed_data and self.instance.status
             == models.STATUS_CHOICES['Ready for review'])):
            send_slack('asr_ready_for_review', snippet)

        return snippet
    def save(self, *args, **kwargs):
        snippet = super().save(*args, **kwargs)

        if (('status' in self.changed_data and
             self.instance.status == models.STATUS_CHOICES['Ready for review'])):
            send_slack('asr_ready_for_review', snippet)

        if (('status' in self.changed_data and
             self.instance.status == models.STATUS_CHOICES['Published'])):
            send_slack('asr_published', snippet)

        return snippet
    def save(self, *args, **kwargs):
        snippet = super(SnippetAdminForm, self).save(commit=False)

        if not self.initial:
            snippet.creator = self.current_user

        if 'ready_for_review' in self.changed_data and self.instance.ready_for_review is True:
            send_slack('legacy_ready_for_review', snippet)

        if 'published' in self.changed_data and self.instance.published is True:
            send_slack('legacy_published', snippet)

        return snippet
    def save(self, *args, **kwargs):
        snippet = super(SnippetAdminForm, self).save(commit=False)

        if not self.initial:
            snippet.creator = self.current_user

        if 'ready_for_review' in self.changed_data and self.instance.ready_for_review is True:
            send_slack('legacy_ready_for_review', snippet)

        if 'published' in self.changed_data and self.instance.published is True:
            send_slack('legacy_published', snippet)

        return snippet
    def make_published(self, request, queryset):
        clean_queryset = queryset.exclude(status=models.STATUS_CHOICES['Published'])
        no_snippets = clean_queryset.count()
        no_already_published_snippets = queryset.count() - no_snippets

        snippets = []
        with transaction.atomic():
            for snippet in clean_queryset:
                snippet.status = models.STATUS_CHOICES['Published']
                snippet.save()
                snippets.append(snippet)

        for snippet in snippets:
            slack.send_slack('asr_published', snippet)

        if no_already_published_snippets:
            messages.warning(
                request, f'Skipped {no_already_published_snippets} already published snippets.')
        messages.success(request, f'Published {no_snippets} snippets.')
Exemple #6
0
    def save(self, *args, **kwargs):
        snippet = super(SnippetAdminForm, self).save(commit=False)

        if not self.initial:
            snippet.creator = self.current_user

        client_options = {}
        for key, value in self.cleaned_data.items():
            if key.startswith('client_option_'):
                client_options[key.split('client_option_', 1)[1]] = value
        snippet.client_options = client_options
        snippet.save()

        if 'ready_for_review' in self.changed_data and self.instance.ready_for_review is True:
            send_slack('legacy_ready_for_review', snippet)

        if 'published' in self.changed_data and self.instance.published is True:
            send_slack('legacy_published', snippet)

        return snippet
Exemple #7
0
    def make_published(self, request, queryset):
        clean_queryset = queryset.exclude(
            status=models.STATUS_CHOICES['Published'])
        no_snippets = clean_queryset.count()
        no_already_published_snippets = queryset.count() - no_snippets

        snippets = []
        with transaction.atomic():
            for snippet in clean_queryset:
                snippet.status = models.STATUS_CHOICES['Published']
                snippet.save()
                snippets.append(snippet)

        for snippet in snippets:
            slack.send_slack('asr_published', snippet)

        if no_already_published_snippets:
            messages.warning(
                request,
                f'Skipped {no_already_published_snippets} already published snippets.'
            )
        messages.success(request, f'Published {no_snippets} snippets.')