当前位置: 首页>>代码示例>>Python>>正文


Python messages.INFO属性代码示例

本文整理汇总了Python中django.contrib.messages.INFO属性的典型用法代码示例。如果您正苦于以下问题:Python messages.INFO属性的具体用法?Python messages.INFO怎么用?Python messages.INFO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.contrib.messages的用法示例。


在下文中一共展示了messages.INFO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: form_valid

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def form_valid(self, form):
        base, created = BaseKeyword.objects.get_or_create(term=form.cleaned_data['term'])
        keyword = Keyword()
        keyword.base = base
        keyword.project = self.request.project
        try:
            keyword.save()
        except IntegrityError:
            # The unique_together constraint on Keyword model failed
            # TODO: Handle a more specific error, IntegrityError could be raised by things other than duplicate too
            messages.add_message(
                message=_('You already have that keyword for this project, so we did not add it again.'),
                level=messages.INFO,
                request=self.request,
                extra_tags='module-level'
            )
        return HttpResponseRedirect(self.get_success_url()) 
开发者ID:pixlie,项目名称:oxidizr,代码行数:19,代码来源:views.py

示例2: question_delete

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def question_delete(request: HttpRequest, course_slug: str, activity_slug: str, question_id: str) -> HttpResponse:
    if request.method in ['POST', 'DELETE']:
        quiz = get_object_or_404(Quiz, activity__slug=activity_slug, activity__offering__slug=course_slug)
        if quiz.completed():
            return ForbiddenResponse(request, 'Quiz is completed. You cannot modify questions after the end of the quiz time')
        question = get_object_or_404(Question, quiz=quiz, id=question_id)
        question.status = 'D'
        question.save()
        if quiz.activity.quiz_marking():
            # configured for quiz-based marking: update that so the order matches
            quiz.configure_marking(delete_others=False)
            messages.add_message(request, messages.INFO, 'Updated marking rubric to match quiz questions.')
        messages.add_message(request, messages.SUCCESS, 'Question deleted.')
        LogEntry(userid=request.user.username, description='deleted quiz question id=%i' % (question.id,),
                 related_object=question).save()
        return redirect('offering:quiz:index', course_slug=course_slug, activity_slug=activity_slug)
    else:
        return HttpError(request, status=405, title="Method Not Allowed", error='POST or DELETE requests only.') 
开发者ID:sfu-fas,项目名称:coursys,代码行数:20,代码来源:views.py

示例3: verify_data

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def verify_data(self, request, queryset):
        for season in queryset:
            # Ensure SeasonPlayer objects exist for all paired players
            if season.league.competitor_type == 'team':
                pairings = TeamPlayerPairing.objects.filter(team_pairing__round__season=season)
            else:
                pairings = LonePlayerPairing.objects.filter(round__season=season)
            for p in pairings:
                SeasonPlayer.objects.get_or_create(season=season, player=p.white)
                SeasonPlayer.objects.get_or_create(season=season, player=p.black)
            # Normalize all gamelinks
            bad_gamelinks = 0
            for p in pairings:
                old = p.game_link
                p.game_link, ok = normalize_gamelink(old)
                if not ok:
                    bad_gamelinks += 1
                if p.game_link != old:
                    p.save()
            if bad_gamelinks > 0:
                self.message_user(request,
                                  '%d bad gamelinks for %s.' % (bad_gamelinks, season.name),
                                  messages.WARNING)
        self.message_user(request, 'Data verified.', messages.INFO) 
开发者ID:cyanfish,项目名称:heltour,代码行数:26,代码来源:admin.py

示例4: create_slack_channels

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def create_slack_channels(self, request, queryset):
        team_ids = []
        skipped = 0
        for team in queryset.select_related('season').nocache():
            if not team.season.is_active or team.season.is_completed:
                self.message_user(request,
                                  'The team season must be active and not completed in order to create channels.',
                                  messages.ERROR)
                return
            if len(team.season.tag) > 3:
                self.message_user(request, 'The team season tag is too long to create a channel.',
                                  messages.ERROR)
                return
            if team.slack_channel == '':
                team_ids.append(team.pk)
            else:
                skipped += 1
        signals.do_create_team_channel.send(sender=self, team_ids=team_ids)
        self.message_user(request, 'Creating %d channels. %d skipped.' % (len(team_ids), skipped),
                          messages.INFO)


# ------------------------------------------------------------------------------- 
开发者ID:cyanfish,项目名称:heltour,代码行数:25,代码来源:admin.py

示例5: message_user

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def message_user(self, request, message, level=messages.INFO, extra_tags='',
                     fail_silently=False):
        """
        Send a message to the user. The default implementation
        posts a message using the django.contrib.messages backend.

        Exposes almost the same API as messages.add_message(), but accepts the
        positional arguments in a different order to maintain backwards
        compatibility. For convenience, it accepts the `level` argument as
        a string rather than the usual level number.
        """

        if not isinstance(level, int):
            # attempt to get the level if passed a string
            try:
                level = getattr(messages.constants, level.upper())
            except AttributeError:
                levels = messages.constants.DEFAULT_TAGS.values()
                levels_repr = ', '.join('`%s`' % l for l in levels)
                raise ValueError('Bad message level string: `%s`. '
                        'Possible values are: %s' % (level, levels_repr))

        messages.add_message(request, level, message, extra_tags=extra_tags,
                fail_silently=fail_silently) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:26,代码来源:options.py

示例6: stage_add_form

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def stage_add_form(request, pk=None):
    stage = get_object_or_404(
        Stage, pk=pk)
    if stage.stage.site:
        instance = FieldSightXF(site=stage.stage.site, is_staged=True, is_scheduled=False, stage=stage)
        if request.method == 'POST':
            form = AssignFormToStageForm(request.POST, instance=instance)
            if form.is_valid():
                form.save()
                messages.add_message(request, messages.INFO, 'Form Assigned Successfully.')
                return HttpResponseRedirect(reverse("forms:stages-detail", kwargs={'pk': stage.stage.id}))
        else:
            form = AssignFormToStageForm(instance=instance)
        return render(request, "fsforms/stage_add_form.html", {'form': form, 'obj': stage})
    else:
        if request.method == 'POST':
            form = AssignFormToStageForm(request.POST)
            if form.is_valid():
                form.save()
                messages.add_message(request, messages.INFO, 'Form Assigned Successfully.')
                return HttpResponseRedirect(reverse("forms:stages-detail", kwargs={'pk': stage.stage.id}))
        else:
            form = AssignFormToStageForm()
        return render(request, "fsforms/stage_add_form.html", {'form': form, 'obj': stage}) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:26,代码来源:views.py

示例7: add_proj_manager

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def add_proj_manager(request, pk):
    obj = get_object_or_404(
        Project, pk=pk, is_active=True)
    group = Group.objects.get(name__exact="Project Manager")
    role_obj = UserRole(project=obj, group=group)
    scenario = 'Assign'
    if request.method == 'POST':
        form = SetProjectManagerForm(data=request.POST, instance=role_obj, request=request)
        if form.is_valid():
            role_obj = form.save(commit=False)
            user_id = request.POST.get('user')
            role_obj.user_id = int(user_id)
            role_obj.save()
        messages.add_message(request, messages.INFO, 'Project Manager Added')
        return HttpResponseRedirect(reverse("fieldsight:project-dashboard", kwargs={'pk': obj.pk}))
    else:
        form = SetProjectManagerForm(instance=role_obj, request=request)
    return render(request, "fieldsight/add_project_manager.html", {'obj':obj,'form':form, 'scenario':scenario}) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:20,代码来源:views.py

示例8: add_supervisor

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def add_supervisor(request, pk):
    obj = get_object_or_404(
        Site, pk=int(pk), is_active=True)
    group = Group.objects.get(name__exact="Site Supervisor")
    role_obj = UserRole(site=obj, group=group)
    if request.method == 'POST':
        form = SetSupervisorForm(data=request.POST, instance=role_obj, request=request)
        if form.is_valid():
            role_obj = form.save(commit=False)
            user_id = request.POST.get('user')
            role_obj.user_id = int(user_id)
            role_obj.save()
        messages.add_message(request, messages.INFO, 'Site Supervisor Added')
        return HttpResponseRedirect(reverse("fieldsight:site-dashboard", kwargs={'pk': obj.pk}))
    else:
        form = SetSupervisorForm(instance=role_obj, request=request)
    return render(request, "fieldsight/add_supervisor.html", {'obj':obj,'form':form}) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:19,代码来源:views.py

示例9: add_central_engineer

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def add_central_engineer(request, pk):
    obj = get_object_or_404(
        Project, pk=pk, is_active=True)
    group = Group.objects.get(name__exact="Reivewer")
    role_obj = UserRole(project=obj, group=group)
    scenario = 'Assign'
    if request.method == 'POST':
        form = SetProjectRoleForm(data=request.POST, instance=role_obj, request=request)
        if form.is_valid():
            role_obj = form.save(commit=False)
            user_id = request.POST.get('user')
            role_obj.user_id = int(user_id)
            role_obj.save()
        messages.add_message(request, messages.INFO, 'Reviewer Added')
        return HttpResponseRedirect(reverse("fieldsight:project-dashboard", kwargs={'pk': obj.pk}))
    else:
        form = SetProjectRoleForm(instance=role_obj, request=request,)
    return render(request, "fieldsight/add_central_engineer.html", {'obj':obj,'form':form, 'scenario':scenario}) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:20,代码来源:views.py

示例10: message_user

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def message_user(self, request, message, level=messages.INFO, extra_tags='',
                     fail_silently=False):
        """
        Send a message to the user. The default implementation
        posts a message using the django.contrib.messages backend.

        Exposes almost the same API as messages.add_message(), but accepts the
        positional arguments in a different order to maintain backwards
        compatibility. For convenience, it accepts the `level` argument as
        a string rather than the usual level number.
        """
        if not isinstance(level, int):
            # attempt to get the level if passed a string
            try:
                level = getattr(messages.constants, level.upper())
            except AttributeError:
                levels = messages.constants.DEFAULT_TAGS.values()
                levels_repr = ', '.join('`%s`' % l for l in levels)
                raise ValueError(
                    'Bad message level string: `%s`. Possible values are: %s'
                    % (level, levels_repr)
                )

        messages.add_message(request, level, message, extra_tags=extra_tags, fail_silently=fail_silently) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:26,代码来源:options.py

示例11: get_queryset

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def get_queryset(self):
        form = self.form_class(self.request.GET)
        if form.is_valid():
            form_data = form.cleaned_data
            if 'wikidata.org' in form_data['project']:
                hashtag_qs = []
                messages.add_message(self.request, messages.INFO,
                # Translators: Message to be displayed when a user specify 'wikidata' in the project field.
                _('Unfortunately Wikidata searching is not currently supported.'))
            else:    
                hashtag_qs = hashtag_queryset(form_data)

                if not hashtag_qs:
                    messages.add_message(self.request, messages.INFO,
                    # Translators: Message to be displayed when there are no results for the search.
                    _('No results found.'))                     

            return hashtag_qs

        # We're mixing forms and listview; paginate_by expects to always
        # have *something* to paginate, so we send back an empty list
        # if the form hasn't been filled yet.
        return [] 
开发者ID:WikipediaLibrary,项目名称:hashtags,代码行数:25,代码来源:views.py

示例12: send_async_mdn

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def send_async_mdn(request, *args, **kwargs):
    """Send all pending asynchronous MDNs to all partners"""
    # Setup the python and django paths
    python_executable_path = pyas2init.gsettings['python_path']
    managepy_path = pyas2init.gsettings['managepy_path']

    # execute the django admin command "sendasyncmdn" to transfer the file to partner
    lijst = [python_executable_path, managepy_path, 'sendasyncmdn']
    pyas2init.logger.info(_(u'Send async MDNs started with parameters: "%(parameters)s"'), {'parameters': str(lijst)})
    try:
        subprocess.Popen(lijst).pid
    except Exception as msg:
        notification = _(u'Errors while trying to run send async MDNs: "%s".') % msg
        messages.add_message(request, messages.INFO, notification)
    else:
        messages.add_message(request, messages.INFO, _(u'Sending all pending asynchronous MDNs .....'))
    return HttpResponseRedirect(reverse('home')) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:19,代码来源:views.py

示例13: retry_failed_comms

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def retry_failed_comms(request, *args, **kwargs):
    """ Retry communications for all failed outbound messages"""
    # Setup the python and django paths
    python_executable_path = pyas2init.gsettings['python_path']
    managepy_path = pyas2init.gsettings['managepy_path']

    # execute the django admin command "retryfailedas2comms" to transfer the file to partner
    lijst = [python_executable_path, managepy_path, 'retryfailedas2comms']
    pyas2init.logger.info(_(u'Retry Failed communications started with parameters: "%(parameters)s"'),
                          {'parameters': str(lijst)})
    try:
        subprocess.Popen(lijst).pid
    except Exception as msg:
        notification = _(u'Errors while trying to retrying failed communications: "%s".') % msg
        messages.add_message(request, messages.INFO, notification)
    else:
        messages.add_message(request, messages.INFO, _(u'Retrying failed communications .....'))
    return HttpResponseRedirect(reverse('home')) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:20,代码来源:views.py

示例14: form_valid

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def form_valid(self, form):
        res = super().form_valid(form)
        LogEntry(userid=self.request.user.username, description='edited quiz id=%i' % (self.object.id,),
                 related_object=self.object).save()

        messages.add_message(self.request, messages.SUCCESS, 'Quiz details updated.')

        if self.object.activity.due_date != self.object.end:
            self.object.activity.due_date = self.object.end
            self.object.activity.save()
            messages.add_message(self.request, messages.INFO, 'Updated %s due date to match quiz end.' % (self.object.activity.name,))

        return res 
开发者ID:sfu-fas,项目名称:coursys,代码行数:15,代码来源:views.py

示例15: question_reorder

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import INFO [as 别名]
def question_reorder(request: HttpRequest, course_slug: str, activity_slug: str, question_id: str) -> HttpResponse:
    quiz = get_object_or_404(Quiz, activity__slug=activity_slug, activity__offering__slug=course_slug)
    question1 = get_object_or_404(Question, quiz=quiz, id=question_id)

    direction = request.GET.get('direction', '')
    if direction not in ['up', 'down']:
        raise Http404()

    #if quiz.completed():
    #    return ForbiddenResponse(request, 'Quiz is completed. You cannot modify questions after the end of the quiz time')

    try:
        if direction == 'up':
            # find question before this one
            prev_order = Question.objects.filter(quiz=quiz, order__lt=question1.order).aggregate(Max('order'))['order__max']
            question2 = Question.objects.get(quiz=quiz, order=prev_order)
        else:
            # find question after this one
            next_order = Question.objects.filter(quiz=quiz, order__gt=question1.order).aggregate(Min('order'))['order__min']
            question2 = Question.objects.get(quiz=quiz, order=next_order)

    except Question.DoesNotExist:
        # moving up past the start, or down past the end: ignore
        pass

    else:
        o1 = question1.order
        o2 = question2.order
        with transaction.atomic():
            question2.order = o1
            question2.save()
            question1.order = o2
            question1.save()
            if quiz.activity.quiz_marking():
                # configured for quiz-based marking: update that so the order matches
                quiz.configure_marking(delete_others=False)
                messages.add_message(request, messages.INFO, 'Reordered marking rubric to match quiz questions.')

    return HttpResponseRedirect(resolve_url('offering:quiz:index', course_slug=course_slug, activity_slug=activity_slug)
                                + '#q-' + str(question1.id)) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:42,代码来源:views.py


注:本文中的django.contrib.messages.INFO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。