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


Python messages.WARNING属性代码示例

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


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

示例1: verify_data

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [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

示例2: handle_merge_errors

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def handle_merge_errors(response, request, final_work, nb_merged,
                        message_user):
    if response == MergeErrors.NO_ID:
        message_user(request,
                     "Aucun ID n'a été fourni pour la fusion.",
                     level=messages.ERROR)
    if response == MergeErrors.FIELDS_MISSING:
        message_user(request,
                     """Un ou plusieurs des champs requis n'ont pas été remplis.
                          (Détails: {})""".format(", ".join(final_work)),
                     level=messages.ERROR)
    if response == MergeErrors.NOT_ENOUGH_WORKS:
        message_user(request,
                     "Veuillez sélectionner au moins 2 œuvres à fusionner.",
                     level=messages.WARNING)
    if response is None:  # Confirmed
        message_user(request,
                     format_html('La fusion de {:d} œuvres vers <a href="{:s}">{:s}</a> a bien été effectuée.'
                                 .format(nb_merged, final_work.get_absolute_url(), final_work.title))) 
开发者ID:mangaki,项目名称:mangaki,代码行数:21,代码来源:admin.py

示例3: article_decision_not_made

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def article_decision_not_made(func):
    """
    This decorator pulls a review and checks if it is accepted or declined. Raises a permission error if
    a decision has already been made.

    :param func: the function to callback from the decorator
    :return: either the function call or raises an PermissionDenied
    """

    def wrapper(request, *args, **kwargs):
        try:
            article_object = models.Article.objects.get(pk=kwargs['article_id'], journal=request.journal)
        except KeyError:
            article_object = review_models.ReviewAssignment.objects.get(pk=kwargs['review_id'],
                                                                        article__journal=request.journal).article

        if article_object.stage == models.STAGE_ASSIGNED or article_object.stage == models.STAGE_UNDER_REVIEW\
                or article_object.stage == models.STAGE_UNDER_REVISION:
            return func(request, *args, **kwargs)
        else:
            messages.add_message(request, messages.WARNING, 'This article has already been accepted or declined.')
            return redirect(reverse('review_in_review', kwargs={'article_id': article_object.pk}))

    return wrapper 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:26,代码来源:decorators.py

示例4: get_pending_update_from_post

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def get_pending_update_from_post(request):
    """
    Gets a VersionQueue object from a post value
    :param request: HttpRequest object
    :return: VersionQueue object or None
    """
    update_id = None

    if 'approve' in request.POST:
        update_id = request.POST.get('approve')
    elif 'deny' in request.POST:
        update_id = request.POST.get('deny')

    if update_id:
        pending_update = get_object_or_404(models.VersionQueue, pk=update_id, date_decision__isnull=True)
        return pending_update
    else:
        messages.add_message(request, messages.WARNING, 'No valid version id provided.')
        return None 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:21,代码来源:logic.py

示例5: handle_updating_subject

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def handle_updating_subject(request, preprint):
    """
    Pulls a subject pk from POST, checks it exists and assigns the article to the subject.
    :param request: HttpRequest
    :param preprint: Preprint Object
    :return: Function does not return anything
    """

    subject_pk = request.POST.get('subject')

    if not subject_pk:
        messages.add_message(request, messages.WARNING, 'No subject selected')
    else:
        subject = get_object_or_404(models.Subject, pk=subject_pk, enabled=True)
        preprint.set_preprint_subject(subject)
        messages.add_message(request, messages.INFO, ('Subject Area updated.')) 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:18,代码来源:logic.py

示例6: move_to_review

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def move_to_review(request, article_id, should_redirect=True):
    """Moves an article into the review stage"""
    article = get_object_or_404(submission_models.Article, pk=article_id)

    if article.editorassignment_set.all().count() > 0:
        article.stage = submission_models.STAGE_ASSIGNED
        article.save()
        review_round, created = models.ReviewRound.objects.get_or_create(article=article, round_number=1)

        if not created:
            messages.add_message(request, messages.WARNING, 'A default review round already exists for this article.')

    else:
        messages.add_message(request, messages.INFO, 'You must assign an editor before moving into reivew.')

    if should_redirect:
        if request.GET.get('return', None):
            return redirect(request.GET.get('return'))
        else:
            return redirect("{0}?modal_id={1}".format(reverse('kanban_home'), article_id)) 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:22,代码来源:views.py

示例7: save_galley_image

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def save_galley_image(galley, request, uploaded_file, label="Galley Image", fixed=False):

    if fixed:
        filename = request.POST.get('file_name')
        uploaded_file_mime = files.check_in_memory_mime(uploaded_file)
        expected_mime = files.guess_mime(filename)

        if not uploaded_file_mime == expected_mime:
            messages.add_message(request, messages.WARNING, 'The file you uploaded does not match the mime of the '
                                                            'file expected.')

    new_file = files.save_file_to_article(uploaded_file, galley.article, request.user)
    new_file.is_galley = False
    new_file.label = label

    if fixed:
        new_file.original_filename = request.POST.get('file_name')

    new_file.save()

    galley.images.add(new_file)

    return new_file 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:25,代码来源:logic.py

示例8: get_search_results

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def get_search_results(self, request, queryset, search_term):
        if (
            self.search_mode_toggle_enabled() and
            not self.djangoql_search_enabled(request)
        ):
            return super(DjangoQLSearchMixin, self).get_search_results(
                request=request,
                queryset=queryset,
                search_term=search_term,
            )
        use_distinct = False
        if not search_term:
            return queryset, use_distinct
        try:
            return (
                apply_search(queryset, search_term, self.djangoql_schema),
                use_distinct,
            )
        except (DjangoQLError, ValueError, FieldError, ValidationError) as e:
            msg = self.djangoql_error_message(e)
            messages.add_message(request, messages.WARNING, msg)
            return queryset.none(), use_distinct 
开发者ID:ivelum,项目名称:djangoql,代码行数:24,代码来源:admin.py

示例9: catch_marking_configuration_error

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def catch_marking_configuration_error(f):
    """
    Decorator to catch MarkingNotConfiguredError and redirect, offering to set things up.
    """
    def decorate(request: HttpRequest, course_slug: str, activity_slug: str, *args, **kwargs):
        with transaction.atomic():
            try:
                return f(request=request, course_slug=course_slug, activity_slug=activity_slug, *args, **kwargs)
            except MarkingNotConfiguredError:
                messages.add_message(request, messages.WARNING, 'Marking is not configured for this quiz.')
                return redirect('offering:quiz:marking_setup', course_slug=course_slug, activity_slug=activity_slug)

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

示例10: show

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def show(request, course_slug, case_slug):
    """
    Display current case status
    """
    course = get_object_or_404(CourseOffering, slug=course_slug)
    case = get_object_or_404(DisciplineCaseBase, slug=case_slug, offering__slug=course_slug)
    case = case.subclass()
    roles = request.session['discipline-'+course_slug] # get roles from session
    if case.public_attachments_size() > MAX_ATTACHMENTS:
        messages.add_message(request, messages.WARNING, 'Total size of public attachments must be at most %s because of email limitations. Please make some of the attachments private.' % (MAX_ATTACHMENTS_TEXT))
    
    context = {'course': course, 'case': case, 'roles': roles}
    return render(request, "discipline/show.html", context) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:15,代码来源:views.py

示例11: login_2fa

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def login_2fa(request, next_page=None):
    next_page, okay_auth, okay_2fa = _setup_view(request, next_page)

    if not okay_auth:
        # Stale standard-Django authentication: redirect to password login page.
        return HttpResponseRedirect(settings.PASSWORD_LOGIN_URL + '?' + urlencode({'next': next_page}))

    if not okay_2fa:
        # Need to do 2FA for this user.
        devices = list(all_otp_devices(request.maybe_stale_user))
        if not devices:
            messages.add_message(request, messages.WARNING, 'You are required to do two-factor authentication but have no device enabled. You must add one.')
            return HttpResponseRedirect(reverse('otp:add_topt') + '?' + urlencode({'next': next_page}))

        if request.method == 'POST':
            form = TokenForm(data=request.POST, devices=devices)
            if form.is_valid():
                # OTP is valid: record last 2FA time in SessionInfo; have django_otp record what it needs in the session
                SessionInfo.just_2fa(request)
                request.user = request.maybe_stale_user # otp_login looks at request.user
                otp_login(request, form.device)

                l = LogEntry(userid=request.user.username,
                    description=("2FA as %s from %s") % (request.user.username, ip.get_ip(request)),
                    related_object=request.user)
                l.save()

                return HttpResponseRedirect(next_page)
        else:
            form = TokenForm()

        context = {
            'form': form,
        }
        return render(request, 'otp/login_2fa.html', context)

    return HttpResponseRedirect(next_page) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:39,代码来源:views.py

示例12: add_change_record

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def add_change_record(request, asset_slug):
    asset = get_object_or_404(Asset, slug=asset_slug, unit__in=request.units)
    if request.method == 'POST':
        form = AssetChangeForm(request, request.POST)
        if form.is_valid():
            change = form.save(commit=False)
            change.asset = asset
            qty = int(form.cleaned_data['qty'])
            #  If no one has ever put in a quantity for the asset, make it 0 to avoid adding int to Nonetype
            if not asset.quantity:
                asset.quantity = 0
            if qty + asset.quantity < 0:
                messages.add_message(request, messages.WARNING, 'You tried to remove more of this asset than you '
                                                                'originally had.  Asset quantity set to zero.')
                asset.quantity = 0
            else:
                asset.quantity += qty
            asset.save()
            change.save(request.user.username)
            messages.add_message(request, messages.SUCCESS, 'Asset change record added')
            l = LogEntry(userid=request.user.username, description="Added change record %s for asset %s" %
                                                                   (change, asset), related_object=change)
            l.save()
            return HttpResponseRedirect(reverse('inventory:view_asset', kwargs={'asset_slug': asset.slug}))
    else:
        form = AssetChangeForm(request)

    return render(request, 'inventory/add_change_record.html', {'form': form, 'asset': asset}) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:30,代码来源:views.py

示例13: delete_change_record

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def delete_change_record(request, record_id):
    record = get_object_or_404(AssetChangeRecord, pk=record_id, asset__unit__in=request.units)
    asset = record.asset
    record.delete(request.user.username)
    messages.success(request, 'Successfully hid record')
    l = LogEntry(userid=request.user.username,
                 description="Deleted record: %s" % record,
                 related_object=record)
    l.save()
    messages.warning(request, 'WARNING:  Quantity for this asset has not been changed.  If deleting this '
                              'record implies quantity changes, please adjust the asset quantity now.')
    return HttpResponseRedirect(reverse('inventory:view_asset', kwargs={'asset_slug': asset.slug})) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:14,代码来源:views.py

示例14: import_marks

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def import_marks(request, course_slug, activity_slug):
    """
    Import JSON marking data
    """
    with django.db.transaction.atomic():
        course = get_object_or_404(CourseOffering, slug=course_slug)
        acts = all_activities_filter(course, slug=activity_slug)
        if len(acts) != 1:
            raise Http404('No such Activity.')
        activity = acts[0]
        
        if request.method == 'POST':
            form = ImportMarkFileForm(data=request.POST, files=request.FILES, activity=activity, userid=request.user.username)
            if form.is_valid():
                found, not_found = activity_marks_from_JSON(activity, request.user.username, form.cleaned_data['file'], save=True)
                messages.add_message(request, messages.SUCCESS, "Successfully imported %i marks." % (len(found)))

                if len(not_found) > 0:
                    for n in not_found:
                        messages.add_message(request, messages.WARNING,
                                             "The following group/userid was not found in the class list and was "
                                             "ignored: %s." % n)
                l = LogEntry(userid=request.user.username,
                             description=("%s bulk marked via JSON file %s for %s. %i grade(s) successfully changed, "
                                          "%i group/userid not found and ignored.") %
                                         (request.user.username, request.FILES['file'], activity, len(found), len(not_found)),
                             related_object=activity)
                l.save()
                return _redirct_response(request, course_slug, activity_slug)
        else:
            form = ImportMarkFileForm(activity=activity, userid=request.user.username)
        
        groups = None
        if activity.group:
            # collect groups so we can report slugs
            groups = set((gm.group for gm in GroupMember.objects.filter(activity=activity).select_related('group')))
        
        components = ActivityComponent.objects.filter(numeric_activity=activity, deleted=False)
        context = {'course': course, 'activity': activity, 'components': components, 'groups': groups, 'form': form}
        return render(request, "marking/import_marks.html", context) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:42,代码来源:views.py

示例15: new_contract

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import WARNING [as 别名]
def new_contract(request, unit_slug, semester):
    hiring_semester = get_object_or_404(HiringSemester, 
                                        semester__name=semester, 
                                        unit__in=request.units,
                                        unit__label=unit_slug)
    if request.method == 'POST':
        form = TAContractForm(hiring_semester, request.POST)
        if form.is_valid():
            contract = form.save(commit=False)
            contract.created_by = request.user.username
            contract.hiring_semster = hiring_semester
            contract.save()
            if contract.payperiods == 0:
                messages.add_message(request, messages.WARNING,
                                     'You have entered 0 pay periods.  This TA will never get paid.')
            messages.add_message(request, 
                                 messages.SUCCESS, 
                                 'Contract %s created.' % str(contract))
            l = LogEntry(userid=request.user.username,
                         description="Created contract %s." % str(contract),
                         related_object=contract)
            l.save()
            return _contract_redirect(unit_slug, semester, contract.slug)
    else:
        form = TAContractForm(hiring_semester, initial={
            'deadline_for_acceptance':hiring_semester.deadline_for_acceptance,
            'appointment_start':hiring_semester.pay_start,
            'appointment_end':hiring_semester.pay_end,
            'pay_start':hiring_semester.pay_start,
            'pay_end':hiring_semester.pay_end,
            'payperiods':hiring_semester.payperiods
        })
    return render(request, 'tacontracts/new_contract.html', {
                  'unit_slug':unit_slug,
                  'semester':semester,
                  'form':form}) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:38,代码来源:views.py


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