コード例 #1
0
    def __init__(self, *args, **kwargs):
        self.legend = kwargs.pop('legend', 'Entry')
        self.compo = kwargs.pop('compo', None)
        self.editing = kwargs.pop('editing', False)

        # Max sizes for filefields
        self.max_source_size = self.compo.source_sizelimit
        self.max_entry_size = self.compo.entry_sizelimit

        # Layout for uni-form ext.
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Fieldset(self.legend, 'name', 'creator', 'description',
                     'entryfile', 'sourcefile', 'imagefile_original',
                     ButtonHolder(Submit('submit', 'Tallenna'))))

        # Create the fields
        super(EntryForm, self).__init__(*args, **kwargs)

        # Give the entryfile and sourcefile fields a nicer help_text
        if self.compo:
            self.fields[
                'entryfile'].help_text = u"Tuotospaketti. Sallitut tiedostoformaatit: " + self.compo.readable_entry_formats(
                ) + u'. Tiedoston maksimikoko on ' + sizeformat(
                    self.max_entry_size) + '.'
            self.fields[
                'sourcefile'].help_text = u"Lähdekoodipaketti. Sallitut tiedostoformaatit: " + self.compo.readable_source_formats(
                ) + u'. Tiedoston maksimikoko on ' + sizeformat(
                    self.max_source_size) + '.'

        # If we are editing, then entryfile field is not required
        if self.editing:
            self.fields['entryfile'].required = False
コード例 #2
0
 def __init__(self, *args, **kwargs):
     super(AdminEntryForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Tuotos', 'compo', 'name', 'description', 'creator',
                  'entryfile', 'sourcefile', 'imagefile_original',
                  'youtube_url', 'disqualified', 'disqualified_reason',
                  ButtonHolder(Submit('submit', 'Tallenna'))))
コード例 #3
0
 def __init__(self, *args, **kwargs):
     super(AdminCompoForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Kompo', 'name', 'description', 'adding_end',
                  'editing_end', 'compo_start', 'voting_start',
                  'voting_end', 'entry_sizelimit', 'source_sizelimit',
                  'formats', 'source_formats', 'active',
                  'show_voting_results', 'entry_view_type',
                  ButtonHolder(Submit('submit', 'Tallenna'))))
コード例 #4
0
ファイル: views.py プロジェクト: jefftriplett/opencomparison
def profile_edit(request, template_name="profiles/profile_edit.html"):

    profile = request.user.get_profile()
    form = ProfileForm(request.POST or None, instance=profile)

    if form.is_valid():
        print form.instance.__dict__
        form.save()
        msg = 'Profile edited'
        messages.add_message(request, messages.INFO, msg)
        return HttpResponseRedirect(reverse("profile_detail", kwargs={"github_account": profile.github_account}))

    # TODO - move this to a template
    github_account = """
    <div
        id="div_id_github_account"
        class="ctrlHolder"><label for="id_github_account" >Github account</label><strong>{0}</strong></div>
    """.format(profile.github_account)

    helper = FormHelper()
    helper.form_class = "profile-edit-form"
    helper.layout = Layout(
        Fieldset(
            '',
            HTML(github_account),
            'bitbucket_url',
            'google_code_url',
        ),
        ButtonHolder(
            Submit('edit', 'Edit', css_class="awesome forestgreen"),
        )
    )

    return render(request, template_name,
        {
            "profile": profile,
            "form": form,
            "helper": helper,
        })
コード例 #5
0
 def __init__(self, *args, **kwargs):
     super(VoteCodeAssocForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Syötä äänestyskoodi', 'code', 'formtype',
                  ButtonHolder(Submit('submit', 'Tallenna'))))
コード例 #6
0
 def __init__(self, *args, **kwargs):
     super(RequestVoteCodeForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Pyydä äänestysoikeutta', 'text', 'formtype',
                  ButtonHolder(Submit('submit', 'Pyydä äänestysoikeutta'))))
コード例 #7
0
 def __init__(self, *args, **kwargs):
     super(CreateTokensForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Generoi tokeneita', 'amount',
                  ButtonHolder(Submit('submit', 'Generoi'))))