django.contrib.messages.SUCCESS - python examples

Here are the examples of the python api django.contrib.messages.SUCCESS taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

144 Examples 7

3 View Complete Implementation : project_rule_remove.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def post(self, request, organization, team, project, rule_id):
        path = reverse('sentry-project-rules', args=[organization.slug, project.slug])

        try:
            rule = Rule.objects.get(project=project, id=rule_id)
        except Rule.DoesNotExist:
            return self.redirect(path)

        rule.delete()

        messages.add_message(request, messages.SUCCESS,
            _('The rule was removed.'))

        return self.redirect(path)

3 View Complete Implementation : realm.py
Copyright MIT License
Author : Peter-Slump
def clear_client_tokens(modeladmin, request, queryset):
    OpenIdConnectProfile.objects.filter(realm__in=queryset).update(
        access_token=None,
        expires_before=None,
        refresh_token=None,
        refresh_expires_before=None
    )
    modeladmin.message_user(
        request=request,
        message='Tokens cleared',
        level=messages.SUCCESS
    )

3 View Complete Implementation : orgs.py
Copyright BSD 2-Clause "Simplified" License
Author : GetTogetherComm
@login_required
@verify_csrf(token_key="csrftoken")
def resend_org_invite(request, invite_id):
    invite = get_object_or_404(OrgTeamRequest, id=invite_id)
    send_org_invite(invite)
    invite.requested_date = datetime.datetime.now()
    invite.save()
    messages.add_message(
        request,
        messages.SUCCESS,
        message=_("Your request has been resent to the team administrators."),
    )
    return redirect("manage-teams", org_slug=invite.organization.slug)

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def form_valid(self, form):
        organisation = form.cleaned_data['organisation']
        emails.InitiatorRequest.send(self.request.user,
                                     phone=form.cleaned_data['phone'],
                                     organisation_id=organisation.id)
        messages.add_message(
            self.request,
            messages.SUCCESS,
            _('Request was send.'))
        return super().form_valid(form)

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def form_valid(self, form):
        response = super().form_valid(form)
        messages.add_message(
            self.request, messages.SUCCESS,
            "Welcome back! You have successfully changed your pastword."
        )
        return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : dkarchmer
    def form_valid(self, form):
        self.object = form.save(commit=True)
        if self.request.user.is_authenticated():
            self.object.name = self.request.user.name
            self.object.email = self.request.user.email
            self.object.save()

        messages.add_message(self.request, messages.SUCCESS, 'Your message has been sent.')

        return HttpResponseRedirect('/')

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : openpolis
    def stop_tasks(self, request, queryset):
        """Remove selected tasks, stop tasks if scheduled, before removing them."""
        for obj in queryset:
            obj.stop()
        self.message_user(
            request,
            f"{len(queryset)} tasks successfully stopped",
            level=messages.SUCCESS,
        )

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_annotated_galley_upload(request, proofing_task, article):
    uploaded_files = request.FILES.getlist('file')

    if uploaded_files:
        for file in uploaded_files:
            new_file = files.save_file_to_article(file, article, request.user)
            new_file.label = 'Annotated Proof'
            new_file.save()
            proofing_task.proofed_files.add(new_file)
            messages.add_message(request, messages.SUCCESS, 'Annotated file uploaded.')
        return None
    else:
        return 'uploadbox'

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : savoirfairelinux
    def form_valid(self, form):
        form.instance.author = self.request.user
        response = super(NoteAdd, self).form_valid(form)
        messages.add_message(
            self.request, messages.SUCCESS,
            _("The note has been created.")
        )
        return response

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def delete_field(request):
    """
    Deletes a field object
    :param request: HttpRequest
    :return: None, adds a Message obejct to request
    """

    delete_id = request.POST.get('delete')
    field_to_delete = get_current_field(request, delete_id)
    field_to_delete.delete()
    messages.add_message(request, messages.SUCCESS, 'Field deleted. Existing answers will remain intact.')

3 View Complete Implementation : views.py
Copyright MIT License
Author : Hopetree
@login_required
def change_profile_view(request):
    if request.method == 'POST':
        old_avatar_file = request.user.avatar.path
        old_avatar_url = request.user.avatar.url
        # 上传文件需要使用request.FILES
        form = ProfileForm(request.POST,request.FILES,instance=request.user)
        if form.is_valid():
            if not old_avatar_url == '/media/avatar/default.png':
                if os.path.exists(old_avatar_file):
                    os.remove(old_avatar_file)
            form.save()
            # 添加一条信息,表单验证成功就重定向到个人信息页面
            messages.add_message(request,messages.SUCCESS,'个人信息更新成功!')
            return redirect('oauth:profile')
    else:
        # 不是POST请求就返回空表单
        form = ProfileForm(instance=request.user)
    return render(request,'oauth/change_profile.html',context={'form':form})

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def form_valid(self, form):
        response = super().form_valid(form)
        # Get user objects from email addresses and invite everyone else
        managers = get_user_model().objects.get_or_invite_users(
            form.cleaned_data['manager_emails'],  # Submitted emails
            self.request  # The email template needs request data
        )
        self.object.managers.set(managers)
        messages.add_message(
            self.request, messages.SUCCESS,
            "{} has been successfully updated!".format(
                self.object.satle)
        )
        self.object.save()  # FIXME: Prevent saving the object twice
        return response

3 View Complete Implementation : product.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : dinoperovic
    def make_active(self, request, queryset):
        rows = queryset.update(active=True)
        if rows == 1:
            msg = _('1 Product was successfully marked as active.')  # pragma: no cover
        else:
            msg = _('%s Products were successfully marked as active.') % rows
        self.message_user(request, msg, messages.SUCCESS)

3 View Complete Implementation : project_issue_tracking.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def _handle_enable_plugin(self, request, project):
        plugin = plugins.get(request.POST['plugin'])
        plugin.enable(project)
        messages.add_message(
            request, messages.SUCCESS,
            constants.OK_PLUGIN_ENABLED.format(name=plugin.get_satle()),
        )

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def use_data_file_as_galley_image(galley, request, label):
    file_id = request.POST.get('datafile')

    if file_id:
        try:
            file = core_models.File.objects.get(pk=file_id)
            file.original_filename = request.POST.get('file_name')
            file.save()
            galley.images.add(file)
            messages.add_message(request, messages.SUCCESS, 'File added.')
        except core_models.File.DoesNotExist:
            messages.add_message(request, messages.WARNING, 'No file with given ID found.')

3 View Complete Implementation : remove_team.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def handle(self, request, organization, team):
        form = self.get_form(request)

        if form.is_valid():
            client.delete('/teams/{}/{}/'.format(organization.slug, team.slug),
                          request=request, is_sudo=True)

            messages.add_message(
                request, messages.SUCCESS,
                _(u'The team %r was scheduled for deletion.') % (team.name.encode('utf-8'),))

            return HttpResponseRedirect(reverse('sentry'))

        context = {
            'form': form,
            'project_list': team.project_set.all(),
        }

        return self.respond('sentry/teams/remove.html', context)

3 View Complete Implementation : new_user.py
Copyright BSD 2-Clause "Simplified" License
Author : GetTogetherComm
@login_required
def setup_complete(request):
    messages.add_message(
        request,
        messages.SUCCESS,
        message=_("Your setup is complete, welcome to GetTogether!"),
    )
    request.user.account.setup_complete()
    return redirect("home")

3 View Complete Implementation : realm.py
Copyright MIT License
Author : Peter-Slump
def refresh_open_id_connect_well_known(modeladmin, request, queryset):
    for realm in queryset:
        django_keycloak.services.realm.refresh_well_known_oidc(realm=realm)
    modeladmin.message_user(
        request=request,
        message='OpenID Connect .well-known refreshed',
        level=messages.SUCCESS
    )

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_unastign_issue(request, article, issues):
    try:
        issue_to_unastign = journal_models.Issue.objects.get(pk=request.POST.get('unastign_issue', None))

        if issue_to_unastign in issues:
            issue_to_unastign.articles.remove(article)
            issue_to_unastign.save()
            messages.add_message(request, messages.SUCCESS, 'Article unastigned from Issue.')
        else:

            messages.add_message(request, messages.WARNING, 'Issue not in this journals issue list.')
    except journal_models.Issue.DoesNotExist:
        messages.add_message(request, messages.WARNING, 'Issue does no exist.')

3 View Complete Implementation : views.py
Copyright MIT License
Author : philgyford
    def form_valid(self, form):
        """
        If the form is valid, redirect to the supplied URL.
        """
        form.save()

        messages.add_message(
            self.request,
            messages.SUCCESS,
            'Changes were saved.'
        )

        return HttpResponseRedirect(self.get_success_url())

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def get_next_page(self):
        # Notify the user that their logout was successful
        messages.add_message(
            self.request, messages.SUCCESS,
            "You've been successfully logged out."
        )
        return super().get_next_page()

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def form_valid(self, form):
        response = super().form_valid(form)
        email = form.cleaned_data['email']
        messages.add_message(
            self.request, messages.SUCCESS,
            "Please check your email {} to reset your pastword. It may take a "
            "few minutes to arrive.".format(email)
        )
        return response

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_set_pubdate(request, article):
    date = request.POST.get('date')
    time = request.POST.get('time')

    date_time_str = "{0} {1}".format(date, time)

    try:
        date_time = dateparser.parse(date_time_str)

        article.date_published = date_time
        article.fixedpubcheckitems.set_pub_date = True
        article.fixedpubcheckitems.save()
        article.save()

        messages.add_message(request, messages.SUCCESS, 'Publication Date set to {0}'.format(date_time_str))

        return [date_time, []]
    except ValueError:
        return [date_time_str, ['Not a recognised Date/Time format. Date: 2016-12-16, Time: 20:20.']]

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def delete(self, request, *args, **kwargs):
        order = self.object = self.get_object()
        success_url = self.get_success_url()

        order.canceled = True
        order.canceled_timestamp = timezone.now()
        order.save()

        messages.add_message(
            self.request, messages.SUCCESS,
            "You've successfully canceled order #{}.".format(order.id)
        )

        return HttpResponseRedirect(success_url)

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : CalthorpeAnalytics
def logout(request):
    django_logout(request)
    response = HttpResponseRedirect('/footprint/login')
    response.set_cookie(key=settings.SPROUTCORE_COOKIE_KEY, expires=datetime.utcnow())
    messages.add_message(request, messages.SUCCESS, "Successfully logged out.")

    return response

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def delete(self, request, *args, **kwargs):
        user = self.object = request.user
        success_url = self.get_success_url()

        user.is_active = False
        user.save()

        messages.add_message(
            self.request, messages.SUCCESS,
            "You've successfully removed your account."
        )

        return HttpResponseRedirect(success_url)

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def form_valid(self, form):
        response = super().form_valid(form)
        messages.add_message(
            self.request, messages.SUCCESS,
            "{} has been successfully created!".format(self.object)
        )
        return response

3 View Complete Implementation : admin.py
Copyright MIT License
Author : dellsystem
def flag_terms(modeladmin, request, queryset):
    queryset.update(flagged=True)
    modeladmin.message_user(
        request,
        'Flagged {n} terms'.format(n=queryset.count()),
        messages.SUCCESS
    )

3 View Complete Implementation : models.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def render_landing_page(
            self, request, form_submission=None, *args, **kwargs):
        if 'HTTP_REFERER' in request.META \
                and request.META.get('HTTP_REFERER'):
            messages.add_message(request, messages.SUCCESS,
                                 self.thank_you_text)
            return redirect(request.META['HTTP_REFERER'])
        return super().render_landing_page(
            request, form_submission, *args, **kwargs)

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_comment_post(request, article, comment):
    comment.article = article
    comment.author = request.user
    comment.save()

    kwargs = {'request': request, 'article': article, 'comment': comment}
    event_logic.Events.raise_event(event_logic.Events.ON_PREPRINT_COMMENT, **kwargs)

    messages.add_message(request, messages.SUCCESS, 'Your comment has been saved. It has been sent for moderation.')

3 View Complete Implementation : views.py
Copyright MIT License
Author : martinstastny
    def form_valid(self, form):
        self.profile = form.save()
        self.request.session['user_cart'] = self.request.session.session_key

        user = authenticate(
            email=self.profile.email,
            pastword=self.request.POST['pastword1']
        )

        messages.add_message(
            self.request, messages.SUCCESS,
            'You were successfully logged in.'
        )

        login(self.request, user)
        return super(RegistrationFormView, self).form_valid(form)

3 View Complete Implementation : product.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : dinoperovic
    def make_inactive(self, request, queryset):
        rows = queryset.update(active=False)
        if rows == 1:
            msg = _('1 Product was successfully marked as inactive.')  # pragma: no cover
        else:
            msg = _('%s Products were successfully marked as inactive.') % rows
        self.message_user(request, msg, messages.SUCCESS)

3 View Complete Implementation : project_issue_tracking.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def _handle_disable_plugin(self, request, project):
        plugin = plugins.get(request.POST['plugin'])
        plugin.disable(project)
        messages.add_message(
            request, messages.SUCCESS,
            constants.OK_PLUGIN_DISABLED.format(name=plugin.get_satle()),
        )

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_astign_issue(request, article, issues):
    try:
        issue_to_astign = journal_models.Issue.objects.get(pk=request.POST.get('astign_issue', None))

        if issue_to_astign in issues:
            issue_to_astign.articles.add(article)
            issue_to_astign.save()
            messages.add_message(request, messages.SUCCESS, 'Article astigned to issue.')
        else:

            messages.add_message(request, messages.WARNING, 'Issue not in this journals issue list.')
    except journal_models.Issue.DoesNotExist:
        messages.add_message(request, messages.WARNING, 'Issue does no exist.')

3 View Complete Implementation : remove_project.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def handle(self, request, organization, team, project):
        form = self.get_form(request)

        if form.is_valid():
            client.delete('/projects/{}/{}/'.format(organization.slug, project.slug),
                          request=request, is_sudo=True)

            messages.add_message(
                request, messages.SUCCESS,
                _(u'The project %r was scheduled for deletion.') % (project.name.encode('utf-8'),))

            return HttpResponseRedirect(reverse('sentry-organization-home', args=[team.organization.slug]))

        context = {
            'form': form,
        }

        return self.respond('sentry/projects/remove.html', context)

3 View Complete Implementation : submission.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, cid):  # pylint: disable=unused-variable
    self.contest.contestparticipant_set.get_or_create(user=self.user)
    self.prepare_submissions()
    if len(self.submissions) > 0:
      for submission in self.submissions:
        submission.pk = None
        submission.contest = self.contest
      Submission.objects.bulk_create(self.submissions)
      invalidate_contest_participant(self.contest, self.user.pk)
      for problem in Problem.objects.filter(pk__in=self.problem_id_list):
        invalidate_problem(problem)
      messages.add_message(request, messages.SUCCESS, "%d 份提交已经成功迁移。" % len(self.submissions))
    return HttpResponse()

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : openpolis
    def response_change(self, request, obj):
        """Determine the HttpResponse for the change_view stage."""
        if "_start-task" in request.POST:
            obj.launch()
            self.message_user(
                request, "This task was successfully launched", level=messages.SUCCESS
            )
            return HttpResponseRedirect(".")
        if "_stop-task" in request.POST:
            obj.stop()
            self.message_user(
                request, "This task was successfully stopped", level=messages.SUCCESS
            )
            return HttpResponseRedirect(".")
        return super().response_change(request, obj)

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def handle_self_typesetter_astignment(production_astignment, request):
    user = get_object_or_404(core_models.Account, pk=request.POST.get('typesetter_id'))
    typeset_task = models.TypesetTask(
        astignment=production_astignment,
        typesetter=user,
        notified=True,
        accepted=timezone.now(),
        typeset_task='This is a self astignment.',
    )

    typeset_task.save()

    messages.add_message(request, messages.SUCCESS, 'You have been astigned as a typesetter to this article.')

    return typeset_task

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : openpolis
    def launch_tasks(self, request, queryset):
        """Launch selected tasks."""
        for obj in queryset:
            obj.launch()
        self.message_user(
            request, f"{len(queryset)} tasks launched", level=messages.SUCCESS
        )

3 View Complete Implementation : new_user.py
Copyright BSD 2-Clause "Simplified" License
Author : GetTogetherComm
@login_required
def user_confirm_email(request, confirmation_key):
    if request.user.account.confirm_email(confirmation_key):
        messages.add_message(
            request,
            messages.SUCCESS,
            message=_("Your email address has been confirmed."),
        )
        ga.add_event(
            request,
            action="email_confirmed",
            category="activity",
            label=str(request.user.profile),
        )

        return redirect("confirm-notifications")
    else:
        return render(request, "get_together/new_user/bad_email_confirmation.html")

3 View Complete Implementation : realm.py
Copyright MIT License
Author : Peter-Slump
def refresh_certs(modeladmin, request, queryset):
    for realm in queryset:
        django_keycloak.services.realm.refresh_certs(realm=realm)
    modeladmin.message_user(
        request=request,
        message='Certificates refreshed',
        level=messages.SUCCESS
    )

3 View Complete Implementation : views.py
Copyright MIT License
Author : avinassh
    def form_valid(self, form):
        user = form.save(commit=False)
        user.is_active = False
        user.save()
        user_service.create_user_profile(user=user)
        user_service.send_activation_email(request=self.request, user=user)
        m = ('Hey {}! Your account has been created. Please check your '
             'email for account activation link.').format(user.username)
        messages.add_message(self.request, messages.SUCCESS, m)
        return redirect('/')

3 View Complete Implementation : views.py
Copyright MIT License
Author : philgyford
    def form_valid(self, form):

        messages.add_message(
            self.request,
            messages.SUCCESS,
            'The publisher was added.'
        )

        return super().form_valid(form)

3 View Complete Implementation : teams.py
Copyright BSD 2-Clause "Simplified" License
Author : GetTogetherComm
@login_required
@verify_csrf(token_key="csrftoken")
def resend_member_invite(request, invite_id):
    invite = get_object_or_404(TeamMembershipRequest, id=invite_id)
    invite_member(invite)
    invite.requested_date = datetime.datetime.now()
    invite.save()
    messages.add_message(
        request, messages.SUCCESS, message=_("Your request has been resent.")
    )
    return redirect("manage-members", team_id=invite.team.id)

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def save_field(request, form):
    """
    Saves a form field and sets the press or journal parameter.
    :param request:
    :param form:
    :return:
    """

    new_field = form.save(commit=False)

    if request.journal:
        new_field.journal = request.journal
    else:
        new_field.press = request.press

    new_field.save()
    messages.add_message(request, messages.SUCCESS, 'Field saved.')
    return new_field

3 View Complete Implementation : admin.py
Copyright GNU Lesser General Public License v3.0
Author : 007gzs
    def mark_valid(self, request, queryset):
        count = 0
        for obj in queryset:
            obj.load_response(obj.test_response, confirm=True)
            obj.save()
            self.log_change(request, obj, 'mark valid')
            count += 1

        self.message_user(request, ungettext(
                'updated %(count)d item',
                'updated %(count)d items',
                count) % {
                    'count': count
            }, messages.SUCCESS)

3 View Complete Implementation : views.py
Copyright MIT License
Author : avinassh
    def form_valid(self, form):
        message = form.cleaned_data['message']
        subject = form.cleaned_data['subject']
        recipients = form.cleaned_data['recipients']
        send_email(subject=subject, message=message, recipient_list=recipients)
        messages.add_message(self.request, messages.SUCCESS,
                             'Emails have been sent!')
        return redirect(reverse('user_manager:mast-email'))

3 View Complete Implementation : logic.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
def set_render_galley(request, article):
    galley_id = request.POST.get('render_galley')

    if galley_id:
        galley = core_models.Galley.objects.get(pk=galley_id)
        article.render_galley = galley
        article.fixedpubcheckitems.select_render_galley = True
        article.fixedpubcheckitems.save()
        article.save()

        messages.add_message(request, messages.SUCCESS, 'Render galley has been set.')
    else:
        messages.add_message(request, messages.WARNING, 'No galley id supplied.')

3 View Complete Implementation : views.py
Copyright MIT License
Author : csev
    def post(self, request) :
        form = BasicForm(request.POST)
        if not form.is_valid() :
            ctx = {'form' : form}
            return render(request, 'crispy/form.html', ctx)

        # Save the Data and send a flash!
        messages.add_message(request, messages.SUCCESS, 'Data saved.')
        return redirect(reverse('crispy_main'))

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : HarvestHub
    def form_valid(self, form):
        response = super().form_valid(form)
        # Get user objects from email addresses and invite everyone else
        gardeners = get_user_model().objects.get_or_invite_users(
            form.cleaned_data['gardener_emails'],  # Submitted emails
            self.request  # The email template needs request data
        )
        self.object.gardeners.set(gardeners)
        self.object.save()  # FIXME: Prevent saving the object twice
        messages.add_message(
            self.request, messages.SUCCESS,
            "{} has been successfully updated!".format(self.object)
        )
        return response