Пример #1
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields["topic"].widget.attrs["class"] = "input-xxlarge"
        self.fields["content"].widget.attrs["class"] = "input-xxlarge monospace"

        self.request = request

        instance = kwargs.get("instance", None)
        if instance is not None:
            self.fields["category"].choices = get_categories(request)
            self.fields["category"].initial = get_category(instance)
        else:
            self.fields["category"].choices = [("", "")] + get_categories(request)
Пример #2
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['topic'].widget.attrs['class'] = 'input-xxlarge'
        self.fields['content'].widget.attrs['class'] = \
                'input-xxlarge monospace'

        self.request = request

        if 'instance' in kwargs:
            self.fields['category'].choices = get_categories(request)
            self.fields['category'].initial = get_category(kwargs['instance'])
        else:
            self.fields['category'].choices = \
                    [('', '')] + get_categories(request)
Пример #3
0
def messages_view(request):
    form, vmsg_kwargs = process_filter_form(request)
    messages = messages_template_context(
        request, visible_messages(request, **vmsg_kwargs)
    )

    if request.user.is_authenticated:
        subscribe_records = QuestionSubscription.objects.filter(
            contest=request.contest, user=request.user
        )
        already_subscribed = len(subscribe_records) > 0
        no_email = request.user.email is None
    else:
        already_subscribed = None
        no_email = None

    return TemplateResponse(
        request,
        'questions/list.html',
        {
            'records': messages,
            'form': form,
            'questions_on_page': getattr(settings, 'QUESTIONS_ON_PAGE', 30),
            'categories': get_categories(request),
            'already_subscribed': already_subscribed,
            'no_email': no_email,
            'onsite': request.contest.controller.is_onsite(),
        },
    )
Пример #4
0
def messages_view(request):
    form, vmsg_kwargs = process_filter_form(request)
    messages = messages_template_context(
        request, visible_messages(request, **vmsg_kwargs))

    if request.user.is_authenticated:
        subscribe_records = QuestionSubscription.objects.filter(
            contest=request.contest, user=request.user
        )
        already_subscribed = len(subscribe_records) > 0
        no_email = request.user.email is None
    else:
        already_subscribed = None
        no_email = None

    return TemplateResponse(request, 'questions/list.html',
        {
            'records': messages, 'form': form,
            'questions_on_page': getattr(settings, 'QUESTIONS_ON_PAGE', 30),
            'categories': get_categories(request),
            'already_subscribed': already_subscribed,
            'no_email': no_email,
            'onsite': request.contest.controller.is_onsite()
        }
    )
Пример #5
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['topic'].widget.attrs['class'] = 'input-xxlarge'
        self.fields['content'].widget.attrs['class'] = 'input-xxlarge monospace'

        self.request = request

        self.fields['category'].choices = get_categories(request)
Пример #6
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['topic'].widget.attrs['class'] = 'input-xxlarge'
        self.fields['content'].widget.attrs[
            'class'] = 'input-xxlarge monospace'

        self.request = request

        self.fields['category'].choices = get_categories(request)
Пример #7
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['content'].widget.attrs['class'] = 'monospace'

        if not is_contest_basicadmin(request):
            del self.fields['pub_date']
        else:
            self.fields['pub_date'].widget = DateTimePicker()
            self.fields['pub_date'].initial = timezone.now()
            # DateTimePicker is always narrow,
            # we don't mark it manually

        self.request = request

        instance = kwargs.get('instance', None)
        if instance is not None:
            self.fields['category'].choices = get_categories(request)
            self.fields['category'].initial = get_category(instance)
        else:
            self.fields['category'].choices = [('', '')] + get_categories(request)
Пример #8
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['topic'].widget.attrs['class'] = 'input-xxlarge'
        self.fields['content'].widget.attrs['class'] = \
                'input-xxlarge monospace'

        if not is_contest_admin(request):
            del self.fields['pub_date']
        else:
            self.fields['pub_date'].widget = DateTimePicker()
            self.fields['pub_date'].initial = timezone.now()

        self.request = request

        instance = kwargs.get('instance', None)
        if instance is not None:
            self.fields['category'].choices = get_categories(request)
            self.fields['category'].initial = get_category(instance)
        else:
            self.fields['category'].choices = \
                    [('', '')] + get_categories(request)
Пример #9
0
    def __init__(self, request, *args, **kwargs):
        super(AddContestMessageForm, self).__init__(*args, **kwargs)
        self.fields['topic'].widget.attrs['class'] = 'input-xxlarge'
        self.fields['content'].widget.attrs['class'] = \
                'input-xxlarge monospace'

        if not is_contest_admin(request):
            del self.fields['pub_date']
        else:
            self.fields['pub_date'].widget = DateTimePicker()
            self.fields['pub_date'].initial = timezone.now()

        self.request = request

        instance = kwargs.get('instance', None)
        if instance is not None:
            self.fields['category'].choices = get_categories(request)
            self.fields['category'].initial = get_category(instance)
        else:
            self.fields['category'].choices = \
                    [('', '')] + get_categories(request)
Пример #10
0
def messages_view(request):
    if is_contest_admin(request):
        form = FilterMessageAdminForm(request, request.GET)
    else:
        form = FilterMessageForm(request, request.GET)

    if form.is_valid():
        category = form.cleaned_data['category']
        author = form.cleaned_data.get('author')
        messages = messages_template_context(
            request, visible_messages(request, author, category))
    else:
        messages = messages_template_context(
            request, visible_messages(request))

    return TemplateResponse(request, 'questions/list.html',
        {'records': messages, 'form': form,
         'questions_on_page': getattr(settings, 'QUESTIONS_ON_PAGE', 30),
         'categories': get_categories(request)})
Пример #11
0
def messages_view(request):
    if is_contest_admin(request):
        form = FilterMessageAdminForm(request, request.GET)
    else:
        form = FilterMessageForm(request, request.GET)

    if form.is_valid():
        category = form.cleaned_data['category']
        author = form.cleaned_data.get('author')
        messages = messages_template_context(
            request, visible_messages(request, author, category))
    else:
        messages = messages_template_context(
            request, visible_messages(request))

    return TemplateResponse(request, 'questions/list.html',
        {'records': messages, 'form': form,
         'questions_on_page': getattr(settings, 'QUESTIONS_ON_PAGE', 30),
         'categories': get_categories(request)})
Пример #12
0
 def __init__(self, request, *args, **kwargs):
     super(FilterMessageForm, self).__init__(*args, **kwargs)
     choices = get_categories(request)
     choices.insert(0, ("all", _("All")))
     self.fields["category"].choices = choices
Пример #13
0
 def __init__(self, request, *args, **kwargs):
     super(FilterMessageForm, self).__init__(*args, **kwargs)
     choices = get_categories(request)
     choices.insert(0, ('all', _("All")))
     self.fields['category'].choices = choices