Ejemplo n.º 1
0
def make_form(request, role, form):
    form.base_fields['can_search_users'] = forms.BooleanField(
        label=_("Can search user profiles"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.base_fields['can_see_users_emails'] = forms.BooleanField(
        label=_("Can see members e-mail's"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.base_fields['can_see_users_trails'] = forms.BooleanField(
        label=_("Can see members ip's and user-agents"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.base_fields['can_see_hidden_users'] = forms.BooleanField(
        label=_("Can see mebers that hide their presence"),
        widget=YesNoSwitch,
        initial=False,
        required=False)

    form.fieldsets.append(
        (_("User Profiles"), ('can_search_users', 'can_see_users_emails',
                              'can_see_users_trails', 'can_see_hidden_users')))
Ejemplo n.º 2
0
class UserSignupForm(SignupForm):
    email = forms.EmailField(
        max_length=80,
        required=True,
        label="E-mail",
        widget=forms.EmailInput(attrs={
            'placeholder': 'Your e-mail address',
            'class': 'form-control'
        }))
    first_name = forms.CharField(
        max_length=50,
        required=False,
        label="First name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your first name',
            'class': 'form-control'
        }))
    last_name = forms.CharField(
        max_length=50,
        required=False,
        label="Last name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your last name',
            'class': 'form-control'
        }))
    terms_of_service = forms.BooleanField(required=True)
    newsletter = forms.BooleanField(required=False)

    def signup(self, request, user):
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name']
        user.save()
        if self.cleaned_data.get('newsletter'):
            user.subscribe_to_newsletter(request)
Ejemplo n.º 3
0
def make_form(request, role, form):
    if role.special != 'guest':
        form.base_fields['can_report_content'] = forms.BooleanField(
            label=_("Can report content"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_handle_reports'] = forms.BooleanField(
            label=_("Can handle reports"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_upload_report_attachments'] = forms.BooleanField(
            label=_("Can upload attachments in reports discussions"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields[
            'can_download_report_attachments'] = forms.BooleanField(
                label=_("Can download attachments in reports discussions"),
                widget=YesNoSwitch,
                initial=False,
                required=False)
        form.base_fields['report_attachment_size'] = forms.IntegerField(
            label=_(
                "Max size of single attachment in reports discussions (in Kb)"
            ),
            help_text=_("Enter zero for no limit."),
            min_value=0,
            initial=100)
        form.base_fields['report_attachment_limit'] = forms.IntegerField(
            label=_(
                "Max number of attachments per post in reports discussions"),
            help_text=_("Enter zero for no limit."),
            min_value=0,
            initial=3)
        form.base_fields['can_mod_reports_discussions'] = forms.BooleanField(
            label=_("Can moderate reports discussions"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_delete_reports'] = forms.TypedChoiceField(
            label=_("Can delete reports"),
            choices=(
                (0, _("No")),
                (1, _("Yes, soft-delete")),
                (2, _("Yes, hard-delete")),
            ),
            coerce=int)

        form.fieldsets.append(
            (_("Reporting Content"),
             ('can_report_content', 'can_handle_reports',
              'can_upload_report_attachments',
              'can_download_report_attachments', 'report_attachment_size',
              'report_attachment_limit', 'can_mod_reports_discussions',
              'can_delete_reports')))
Ejemplo n.º 4
0
class UserSignupForm(SignupForm):

    email = forms.EmailField(
        max_length=80,
        required=True,
        label="E-mail",
        widget=forms.EmailInput(attrs={
            'placeholder': 'Your e-mail address',
            'class': 'form-control'
        }))
    email2 = forms.EmailField(
        max_length=80,
        required=True,
        label="Confirm E-mail",
        widget=forms.EmailInput(attrs={
            'placeholder': 'Confirm your e-mail address',
            'class': 'form-control'
        }))
    first_name = forms.CharField(
        max_length=50,
        required=False,
        label="First name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your first name',
            'class': 'form-control'
        }))
    last_name = forms.CharField(
        max_length=50,
        required=False,
        label="Last name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your last name',
            'class': 'form-control'
        }))
    terms_of_service = forms.BooleanField(required=False)
    newsletter = forms.BooleanField(required=False)
    privacy = forms.BooleanField()

    def __init__(self, *args, **kwargs):

        ignore_email2 = kwargs.pop('ignore_email2')
        data = super(UserSignupForm, self).__init__(*args, **kwargs)
        if ignore_email2:
            self.fields['email2'].required = False

        return data

    def signup(self, request, user):
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name']
        user.save()
        if self.cleaned_data.get('newsletter'):
            user.subscribe_to_newsletter(request)
Ejemplo n.º 5
0
class UserSettingsForm(forms.Form):
    login_view_ticketlist = forms.BooleanField(
        label=_('Show Ticket List on Login?'),
        help_text=
        _('Display the ticket list upon login? Otherwise, the dashboard is shown.'
          ),
        required=False,
    )

    email_on_ticket_change = forms.BooleanField(
        label=_('E-mail me on ticket change?'),
        help_text=
        _('If you\'re the ticket owner and the ticket is changed via the web by somebody else, do you want to receive an e-mail?'
          ),
        required=False,
    )

    email_on_ticket_assign = forms.BooleanField(
        label=_('E-mail me when assigned a ticket?'),
        help_text=
        _('If you are assigned a ticket via the web, do you want to receive an e-mail?'
          ),
        required=False,
    )

    email_on_ticket_apichange = forms.BooleanField(
        label=_('E-mail me when a ticket is changed via the API?'),
        help_text=
        _('If a ticket is altered by the API, do you want to receive an e-mail?'
          ),
        required=False,
    )

    tickets_per_page = forms.IntegerField(
        label=_('Number of tickets to show per page'),
        help_text=_(
            'How many tickets do you want to see on the Ticket List page?'),
        required=False,
        min_value=1,
        max_value=1000,
    )

    use_email_as_submitter = forms.BooleanField(
        label=_('Use my e-mail address when submitting tickets?'),
        help_text=
        _('When you submit a ticket, do you want to automatically use your e-mail address as the submitter address? You can type a different e-mail address when entering the ticket if needed, this option only changes the default.'
          ),
        required=False,
    )
Ejemplo n.º 6
0
def make_forum_form(request, role, form):
    form.base_fields['can_see_forum'] = forms.BooleanField(
        label=_("Can see forum"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.base_fields['can_see_forum_contents'] = forms.BooleanField(
        label=_("Can see forum contents"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.fieldsets.append((
        _("Forums Permissions"),
        ('can_see_forum', 'can_see_forum_contents'),
    ))
Ejemplo n.º 7
0
class TermsForm(forms.Form):
    terms = forms.BooleanField(
        label=mark_safe(_("Terms and Conditions and Privacy Statement")),
        error_messages={
            'required':
            _('You need to accept our Terms and Conditions and Priavcy Statement.'
              )
        },
        widget=AgreeCheckboxInput(agree_to=_(
            u'You agree to our <a href="%(url_terms)s" class="target-new">Terms and Conditions</a> and <a href="%(url_privacy)s" class="target-new">Privacy Statement</a>'
        ),
                                  url_names={
                                      "url_terms": "help-terms",
                                      "url_privacy": "help-privacy"
                                  }))

    def __init__(self, *args, **kwargs):
        super(TermsForm, self).__init__(*args, **kwargs)
        if HAVE_NEWSLETTER():
            self.fields['newsletter'] = forms.BooleanField(
                required=False,
                label=_("Check if you want to receive our newsletter."))

    def save(self, user):
        user.terms = True
        if HAVE_NEWSLETTER():
            user.newsletter = self.cleaned_data['newsletter']
        user.save()
Ejemplo n.º 8
0
class BaseAddCaseForm(forms.Form):
    """Base form for adding cases."""
    product = mtforms.MTModelChoiceField(
        model.Product.objects.all(),
        choice_attrs=lambda p: {"data-product-id": p.id},
    )
    productversion = mtforms.MTModelChoiceField(
        queryset=model.ProductVersion.objects.all(),
        choice_attrs=mtforms.product_id_attrs,
        label_from_instance=lambda pv: pv.version,
    )
    and_later_versions = forms.BooleanField(initial=True, required=False)

    def __init__(self, *args, **kwargs):
        """Initialize form; possibly add suite field."""
        super(BaseAddCaseForm, self).__init__(*args, **kwargs)

        if self.user and self.user.has_perm("library.manage_suite_cases"):
            self.fields["suite"] = mtforms.MTModelChoiceField(
                model.Suite.objects.all(),
                choice_attrs=mtforms.product_id_attrs,
                required=False)

    def clean(self):
        """Verify that products all match up."""
        productversion = self.cleaned_data.get("productversion")
        suite = self.cleaned_data.get("suite")
        product = self.cleaned_data.get("product")
        if product and productversion and productversion.product != product:
            raise forms.ValidationError(
                "Must select a version of the correct product.")
        if product and suite and suite.product != product:
            raise forms.ValidationError(
                "Must select a suite for the correct product.")
        return self.cleaned_data
Ejemplo n.º 9
0
class OrgSearch(forms.Form):
    org_type = forms.ChoiceField(choices=ORG_TYPE_CHOICES, required=False)
    prov_type = forms.ModelChoiceField(queryset=AgreementIAE.objects.all(),
                                       empty_label=u'Tout voir',
                                       required=False)
    interim = forms.BooleanField(required=False)
    sector = forms.ModelChoiceField(
        queryset=ActivityNomenclature.objects.filter(level=0),
        empty_label=u'Tout voir',
        required=False)
    area = AutoCompleteSelectField(lookup_class=AreaLookup, required=False)
    radius = forms.IntegerField(required=False)
    q = forms.CharField(
        required=False,
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'placeholder': 'Recherche libre : mot clés'
        }))

    def __init__(self, *args, **kwargs):
        super(OrgSearch, self).__init__(*args, **kwargs)
        for name, field in self.fields.iteritems():
            if name == 'interim':
                continue
            field.widget.attrs['class'] = 'form-control'
        self.fields['area'].widget.attrs['placeholder'] = u'Tout voir'
        self.fields['area'].widget.attrs[
            'class'] = u'form-control form-control-small'
        self.fields['radius'].widget.attrs['placeholder'] = u'Dans un rayon de'
        self.fields['radius'].widget.attrs[
            'class'] = u'form-control form-control-small'
Ejemplo n.º 10
0
class UserForumOptionsForm(Form):
    newsletters = forms.BooleanField(label=_("Newsletters"),
                                     help_text=_("On occasion board administrator may want to send e-mail message to multiple members."),
                                     required=False)
    timezone = forms.ChoiceField(label=_("Your Current Timezone"),
                                 help_text=_("If dates and hours displayed by forums are inaccurate, you can fix it by adjusting timezone setting."),
                                 choices=tzlist())
    hide_activity = forms.TypedChoiceField(label=_("Your Visibility"),
                                           help_text=_("If you want to, you can limit other members ability to track your presence on forums."),
                                           choices=(
                                                    (0, _("Show my presence to everyone")),
                                                    (1, _("Show my presence to people I follow")),
                                                    (2, _("Show my presence to nobody")),
                                                    ), coerce=int)
    subscribe_start = forms.TypedChoiceField(label=_("Threads I start"),
                                             choices=(
                                                      (0, _("Don't watch")),
                                                      (1, _("Put on watched threads list")),
                                                      (2, _("Put on watched threads list and e-mail me when somebody replies")),
                                                      ), coerce=int)
    subscribe_reply = forms.TypedChoiceField(label=_("Threads I reply to"),
                                             choices=(
                                                      (0, _("Don't watch")),
                                                      (1, _("Put on watched threads list")),
                                                      (2, _("Put on watched threads list and e-mail me when somebody replies")),
                                                      ), coerce=int)
    allow_pds = forms.TypedChoiceField(label=_("Allow Private Threads Invitations"),
                                       help_text=_("If you wish, you can restrict who can invite you to private threads. Keep in mind some groups or members may be allowed to override this preference."),
                                       choices=(
                                                (0, _("From everyone")),
                                                (1, _("From everyone but not members I ignore")),
                                                (2, _("From members I follow")),
                                                (2, _("From nobody")),
                                                ), coerce=int)
Ejemplo n.º 11
0
class EditProfileForm(forms.Form):
    first_name = forms.CharField(
        max_length=50,
        required=False,
        label="First name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your first name',
            'class': 'form-control'
        }))
    last_name = forms.CharField(
        max_length=50,
        required=False,
        label="Last name",
        widget=forms.TextInput(attrs={
            'placeholder': 'Your last name',
            'class': 'form-control'
        }))
    newsletter = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        super(EditProfileForm, self).__init__(*args, **kwargs)
        self.fields['first_name'].initial = self.user.first_name
        self.fields['last_name'].initial = self.user.last_name
        self.fields['newsletter'].initial = self.user.newsletter

    def save(self, request=None):
        self.user.first_name = self.cleaned_data['first_name']
        self.user.last_name = self.cleaned_data['last_name']
        self.user.save()
        if self.cleaned_data.get('newsletter'):
            self.user.subscribe_to_newsletter(request)
        else:
            self.user.unsubscribe_from_newsletter(request)
Ejemplo n.º 12
0
    def finalize_form(self):
        # Can we change threads states?
        if self.include_thread_weight and (self.request.acl.threads.can_pin_threads(self.forum) and
            (not self.thread or self.request.acl.threads.can_pin_threads(self.forum) >= self.thread.weight)):
            thread_weight = []
            if self.request.acl.threads.can_pin_threads(self.forum) == 2:
                thread_weight.append((2, _("Announcement")))
            thread_weight.append((1, _("Sticky")))
            thread_weight.append((0, _("Standard")))
            if thread_weight:
                try:
                    current_weight = self.thread.weight
                except AttributeError:
                    current_weight = 0
                self.add_field('thread_weight', forms.TypedChoiceField(widget=forms.RadioSelect,
                                                                       choices=thread_weight,
                                                                       required=False,
                                                                       coerce=int,
                                                                       initial=current_weight))

        # Can we lock threads?
        if self.include_close_thread and self.request.acl.threads.can_close(self.forum):
            self.add_field('close_thread', forms.BooleanField(required=False))

        if self.request.acl.threads.can_upload_attachments(self.forum):
            self.add_field('new_file', forms.FileField(required=False))

        # Give inheritor chance to set custom fields
        try:
            type_fields_call = self.type_fields
        except AttributeError:
            type_fields_call = None
        if type_fields_call:
            type_fields_call()
Ejemplo n.º 13
0
def make_form(request, role, form):
    if role.special != 'guest':
        form.base_fields['can_warn_members'] = forms.BooleanField(
            label=_("Can warn other members"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_see_other_members_warns'] = forms.BooleanField(
            label=_("Can see other members warnings"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_cancel_warnings'] = forms.TypedChoiceField(
            label=_("Can cancel warnings"),
            widget=forms.Select,
            initial=0,
            coerce=int,
            choices=(
                (0, _("No")),
                (1, _("If is warning giver")),
                (2, _("Yes, all warnings")),
            ))
        form.base_fields['can_cancel_warnings_newer_than'] = forms.IntegerField(
            label=_(
                "Maximum age of warning that can be canceled (in minutes)"),
            help_text=_("Enter zero to disable this limitation."),
            min_value=0,
            initial=15)
        form.base_fields['can_delete_warnings'] = forms.BooleanField(
            label=_("Can delete warnings"),
            widget=YesNoSwitch,
            initial=False,
            required=False)
        form.base_fields['can_be_warned'] = forms.BooleanField(
            label=_("Can be warned"),
            widget=YesNoSwitch,
            initial=False,
            required=False)

        form.fieldsets.append((_("Warning Members"), (
            'can_warn_members',
            'can_see_other_members_warns',
            'can_cancel_warnings',
            'can_cancel_warnings_newer_than',
            'can_delete_warnings',
            'can_be_warned',
        )))
 def field_hook(self):
     if self.instance:
         if self.instance.status.DRAFT:
             self.fields["caseupdate"] = forms.BooleanField(initial=False,
                                                            required=False)
         else:
             # no modifying suites on an active test run
             del self.fields["suites"]
Ejemplo n.º 15
0
 def __init__(self, user, *args, **kwargs):
     super(UserChangeForm, self).__init__(*args, **kwargs)
     self.user = user
     self.fields['address'].initial = self.user.address
     self.fields['email'].initial = self.user.email
     if HAVE_NEWSLETTER():
         self.fields['newsletter'] = forms.BooleanField(required=False,
             label=_("Newsletter"))
         self.fields['newsletter'].initial = self.user.newsletter
Ejemplo n.º 16
0
class DonateForm(forms.Form):
    """Form for accepting a donation."""

    name = pyoforms.StripCharField(max_length=200)
    email = forms.EmailField(max_length=255)
    phone = pyoforms.StripCharField(max_length=20)
    country_code = forms.TypedChoiceField(
        choices=model.Profile._meta.get_field('country_code').choices,
        widget=forms.RadioSelect(),
        )
    school = pyoforms.ModelChoiceField(
        queryset=model.School.objects.filter(auto=False).order_by('name'),
        empty_label=u"I'm not affiliated with a school or program",
        required=False,
        widget=SchoolRadioSelect,
        initial=u'',
        )
    addschool = forms.BooleanField(
        initial=False, required=False, widget=forms.HiddenInput)

    amount = pyoforms.StripCharField(max_length=20)


    def __init__(self, *args, **kwargs):
        """Also instantiate a nested SchoolForm."""
        super(DonateForm, self).__init__(*args, **kwargs)
        self.addschool_form = SchoolForm(self.data or None, prefix='addschool')


    def clean(self):
        """
        Verify password fields match and school is provided.

        If addschool is True, build a new School based on data in nested
        SchoolForm.

        If not, and no school was selected, auto-construct one.

        """
        data = self.cleaned_data
        if data.get('addschool'):
            if self.addschool_form.is_valid():
                data['school'] = self.addschool_form.save(commit=False)
            else:
                raise forms.ValidationError(
                    "Could not add a school.")
        else:
            # reinstantiate unbound addschool_form to avoid spurious errors
            self.addschool_form = SchoolForm(prefix='addschool')
            if data.get('email') and not data.get('school'):
                data['school'] = model.School(
                    name=(u"%f-%s" % (time.time(), data['email']))[:200],
                    postcode="",
                    auto=True,
                    )
        return data
Ejemplo n.º 17
0
class GradeFilterForm(TimeBasedForm):
    marking_period = forms.ModelMultipleChoiceField(required=False, queryset=MarkingPeriod.objects.all())

    filter_choices = (
        ("lt", "Less Than"),
        ("lte", "Less Than Equals"),
        ("gt", "Greater Than"),
        ("gte", "Greater Than Equals"),
    )

    grade = forms.CharField(max_length=5,
                            widget=forms.TextInput(attrs={'placeholder': 'Enter Grade Here'}),
                            required=False,
                            help_text="P counts as 100%, F counts as 0%",)
    grade_filter = forms.ChoiceField(choices=filter_choices)
    grade_times = StarOrIntField(max_length=2, required=False, initial="*", widget=forms.TextInput(attrs={'style':'width:20px;'}))
    final_grade = forms.CharField(max_length=5,
                            widget=forms.TextInput(attrs={'placeholder': 'Enter Grade Here'}),
                            required=False,
                            help_text="P counts as 100%, F counts as 0%",)
    final_grade_filter = forms.ChoiceField(choices=filter_choices)
    final_grade_times = StarOrIntField(max_length=2, required=False, initial="*", widget=forms.TextInput(attrs={'style':'width:20px;'}))

    gpa = forms.DecimalField(max_digits=5, decimal_places=2, required=False)
    gpa_equality =  forms.ChoiceField(choices=filter_choices)
    filter_year = forms.ModelMultipleChoiceField(required=False, queryset=GradeLevel.objects.all())
    in_individual_education_program = forms.BooleanField(required=False)
    #disc
    if 'ecwsp.discipline' in settings.INSTALLED_APPS:
        from ecwsp.discipline.models import DisciplineAction
        filter_disc_action = forms.ModelChoiceField(required=False, queryset=DisciplineAction.objects.all())
        filter_disc = forms.ChoiceField(choices=filter_choices, required=False)
        filter_disc_times = forms.CharField(max_length=2, required=False, widget=forms.TextInput(attrs={'style':'width:20px;'}))
        # Aggregated
        aggregate_disc = forms.ChoiceField(choices=filter_choices, required=False)
        aggregate_disc_times = forms.CharField(max_length=2, required=False, widget=forms.TextInput(attrs={'style':'width:20px;'}))
        aggregate_disc_major = forms.BooleanField(required=False)
    # Absences
    filter_attn = forms.ChoiceField(choices=filter_choices, required=False)
    filter_attn_times = forms.CharField(max_length=2, required=False, widget=forms.TextInput(attrs={'style':'width:20px;'}))
    # Tardies
    filter_tardy = forms.ChoiceField(choices=filter_choices, required=False)
    filter_tardy_times = forms.CharField(max_length=2, required=False, widget=forms.TextInput(attrs={'style':'width:20px;'}))
Ejemplo n.º 18
0
def make_form(request, role, form):
    if role.special != 'guest':
        form.base_fields['name_changes_allowed'] = forms.IntegerField(label=_("Allowed Username changes number"),
                                                                      help_text=_("Enter zero to don't allow users with this role to change their names."),
                                                                      min_value=0, initial=1)
        form.base_fields['changes_expire'] = forms.IntegerField(label=_("Don't count username changes older than"),
                                                                help_text=_("Number of days since name change that makes that change no longer count to limit. For example, if you enter 7 days and set changes limit 3, users with this rank will not be able to make more than three changes in duration of 7 days. Enter zero to make all changes count."),
                                                                min_value=0, initial=0)
        form.base_fields['can_use_signature'] = forms.BooleanField(label=_("Can have signature"),
                                                                   widget=YesNoSwitch, initial=False, required=False)
        form.base_fields['allow_signature_links'] = forms.BooleanField(label=_("Can put links in signature"),
                                                                       widget=YesNoSwitch, initial=False, required=False)
        form.base_fields['allow_signature_images'] = forms.BooleanField(label=_("Can put images in signature"),
                                                                        widget=YesNoSwitch, initial=False, required=False)

        form.fieldsets.append((
                               _("Profile Settings"),
                               ('name_changes_allowed', 'changes_expire', 'can_use_signature', 'allow_signature_links', 'allow_signature_images')
                              ))
Ejemplo n.º 19
0
class EventForm(forms.Form):

    name = forms.CharField(widget=forms.TextInput(
        attrs={'placeholder': 'name your event'}))
    date = forms.DateTimeField(widget=forms.SplitDateTimeWidget)
    location = forms.CharField(widget=forms.TextInput(
        attrs={'placeholder': 'address'}))
    city = forms.CharField(widget=forms.TextInput(
        attrs={'placeholder': 'city'}))
    category = forms.ChoiceField(choices=CategoryOptions().CATEGORY_OPTIONS)
    description = forms.CharField(widget=forms.Textarea(
        attrs={'placeholder': 'don\'t be shy - tell us about it some more'}))
    budget = forms.IntegerField()
    max_people = forms.IntegerField()
    is_vegan = forms.BooleanField(required=False)
    is_kosher = forms.BooleanField(required=False)
    is_vegeterian = forms.BooleanField(required=False)
    rsvp = forms.ChoiceField(widget=forms.RadioSelect,
                             choices=RsvpOptions().RSVP_OPTIONS)
    picture = forms.ImageField()
Ejemplo n.º 20
0
class AllFieldsForm(forms.Form):
    boolean = forms.BooleanField()
    char = forms.CharField(max_length=50)
    choices = forms.ChoiceField(choices=ALPHA_CHOICES)
    date = forms.DateField()
    datetime = forms.DateTimeField()
    decimal = forms.DecimalField(decimal_places=2, max_digits=4)
    email = forms.EmailField()
    file_field = forms.FileField()
    file_path = forms.FilePathField(path='uploads/')
    float_field = forms.FloatField()
    generic_ip_address = forms.GenericIPAddressField()
    image = forms.ImageField()
    integer = forms.IntegerField()
    ip_address = forms.IPAddressField()
    multiple_choices = forms.MultipleChoiceField(choices=ALPHA_CHOICES)
    null_boolean = forms.NullBooleanField()
    regex_field = forms.RegexField(regex='^\w+$', js_regex='^[a-zA-Z]+$')
    slug = forms.SlugField()
    split_datetime = forms.SplitDateTimeField()
    time = forms.TimeField()
    typed_choices = forms.TypedChoiceField(choices=NUMERIC_CHOICES, coerce=int)
    typed_multiple_choices = forms.TypedMultipleChoiceField(
        choices=NUMERIC_CHOICES, coerce=int)
    url = forms.URLField()

    # GIS fields.
    if gis_forms:
        osm_point = gis.PointField(
            widget=mixin(gis.PointWidget, gis.BaseOsmWidget))
        osm_multipoint = gis.MultiPointField(
            widget=mixin(gis.MultiPointWidget, gis.BaseOsmWidget))
        osm_linestring = gis.LineStringField(
            widget=mixin(gis.LineStringWidget, gis.BaseOsmWidget))
        osm_multilinestring = gis.MultiLineStringField(
            widget=mixin(gis.MultiLineStringWidget, gis.BaseOsmWidget))
        osm_polygon = gis.PolygonField(
            widget=mixin(gis.PolygonWidget, gis.BaseOsmWidget))
        osm_multipolygon = gis.MultiPolygonField(
            widget=mixin(gis.MultiPolygonWidget, gis.BaseOsmWidget))

        gmap_point = gis.PointField(
            widget=mixin(gis.PointWidget, BaseGMapWidget))
        gmap_multipoint = gis.MultiPointField(
            widget=mixin(gis.MultiPointWidget, BaseGMapWidget))
        gmap_linestring = gis.LineStringField(
            widget=mixin(gis.LineStringWidget, BaseGMapWidget))
        gmap_multilinestring = gis.MultiLineStringField(
            widget=mixin(gis.MultiLineStringWidget, BaseGMapWidget))
        gmap_polygon = gis.PolygonField(
            widget=mixin(gis.PolygonWidget, BaseGMapWidget))
        gmap_multipolygon = gis.MultiPolygonField(
            widget=mixin(gis.MultiPolygonWidget, BaseGMapWidget))
Ejemplo n.º 21
0
 def create_poll_form(self):
     self.add_field(
         'poll_question',
         forms.CharField(label=_("Poll Question"), required=False))
     self.add_field(
         'poll_choices',
         forms.CharField(
             label=_("Poll Choices"),
             help_text=
             _("Enter options poll members will vote on, every one in new line."
               ),
             required=False,
             widget=forms.Textarea))
     self.add_field(
         'poll_max_choices',
         forms.IntegerField(
             label=_("Choices Per User"),
             help_text=
             _("Select on how many options individual user will be able to vote on."
               ),
             min_value=1,
             initial=1))
     self.add_field(
         'poll_length',
         forms.IntegerField(
             label=_("Poll Length"),
             help_text=
             _("Number of days since poll creations users will be allowed to vote in poll. Enter zero for permanent poll."
               ),
             min_value=0,
             initial=0))
     self.add_field(
         'poll_public',
         forms.BooleanField(label=_("Public Voting"), required=False))
     self.add_field(
         'poll_changing_votes',
         forms.BooleanField(label=_("Allow Changing Votes"),
                            required=False))
Ejemplo n.º 22
0
class StudentBulkChangeForm(forms.Form):
    grad_date = forms.DateField(widget=adminwidgets.AdminDateWidget(),
                                required=False,
                                validators=settings.DATE_VALIDATORS)
    year = forms.ModelChoiceField(queryset=GradeLevel.objects.all(),
                                  required=False)
    individual_education_program = forms.NullBooleanField(required=False)
    cohort = forms.ModelChoiceField(queryset=Cohort.objects.all(),
                                    required=False)
    cohort_primary = forms.BooleanField(required=False)
    award = forms.ModelChoiceField(queryset=Award.objects.all(),
                                   required=False)
    award_marking_period = forms.ModelChoiceField(
        queryset=MarkingPeriod.objects.all(), required=False)
Ejemplo n.º 23
0
class ProjectSearchForm(FacetedSearchForm):
    q = forms.CharField(required=False, label=_('Search'))
    best_of = forms.BooleanField(required=False, label=_('Best of'))
    has_team = forms.BooleanField(required=False, label=_('Has team'))
    has_needs = forms.BooleanField(required=False, label=_('Has needs'))
    countries = forms.CharField(required=False, label=_('Location'))
    language_codes = forms.CharField(required=False, label=_('Language'))
    tags = forms.CharField(required=False, label=_('Tags'))
    order = forms.CharField(required=False, label=_('Order'))
    status = forms.CharField(required=False,
                             label=_('Status'),
                             widget=forms.widgets.HiddenInput)

    def search(self):
        sqs = self.searchqueryset

        if not self.is_valid():
            # FIXME Would need a random here
            return sqs.load_all().order_by('?')

        if self.cleaned_data.get('q'):
            sqs = self.searchqueryset.auto_query(self.cleaned_data['q'])

        # I4P Project sheet criteria
        filters = {}
        for field in ('best_of', 'has_team', 'has_needs', 'countries',
                      'language_codes', 'tags', 'status'):
            data = self.cleaned_data.get(field)
            if data and data != "":
                filters[field] = self.cleaned_data[field]

        sqs = sqs.filter(**filters)

        if self.load_all:
            sqs = sqs.load_all()

        return sqs
Ejemplo n.º 24
0
class SignInForm(Form):
    user_email = forms.EmailField(max_length=255, label=_("Seu email"))
    user_password = forms.CharField(widget=forms.PasswordInput,
                                    max_length=255,
                                    label=_("Sua senha"))
    user_remember_me = forms.BooleanField(label=_("Fique conectado"),
                                          help_text=_("Lembre de mim"),
                                          required=False)

    def __init__(self, *args, **kwargs):
        show_remember_me = kwargs.pop('show_remember_me')

        super(SignInForm, self).__init__(*args, **kwargs)
        if not show_remember_me:
            del self.fields['user_remember_me']
Ejemplo n.º 25
0
class SignInForm(Form):
    user_email = forms.EmailField(max_length=255, label=_("Your email"))
    user_password = forms.CharField(widget=forms.PasswordInput,
                                    max_length=255,
                                    label=_("Your password"))
    user_remember_me = forms.BooleanField(
        label=_("Stay Signed In"),
        help_text=_("Sign me In automatically next time"),
        required=False)

    def __init__(self, *args, **kwargs):
        show_remember_me = kwargs.pop('show_remember_me')

        super(SignInForm, self).__init__(*args, **kwargs)
        if not show_remember_me:
            del self.fields['user_remember_me']
Ejemplo n.º 26
0
def make_form(request, role, form):
    form.base_fields['can_search_forums'] = forms.BooleanField(
        label=_("Can search community"),
        widget=YesNoSwitch,
        initial=False,
        required=False)
    form.base_fields['search_cooldown'] = forms.IntegerField(
        label=_("Minimum delay between searches"),
        help_text=
        _("Forum search can be resources intensive operation, and so its usually good idea to limit frequency of searches by requiring members to wait certain number of seconds before they can perform next search. Enter 0 to disable this requirement."
          ),
        initial=25,
        min_value=0)

    form.fieldsets.append(
        (_("Searching"), ('can_search_forums', 'search_cooldown')))
Ejemplo n.º 27
0
 def finalize_form(self):
     self.add_field(
         'search_forums',
         ForumMultipleChoiceField(
             label=_("Search Forums"),
             help_text=_(
                 "If you want, you can limit search to specified forums."),
             queryset=Forum.objects.get(
                 special='root').get_descendants().filter(
                     pk__in=self.request.acl.forums.acl['can_browse']),
             required=False,
             empty_label=None,
             widget=forms.SelectMultiple))
     self.add_field(
         'search_forums_childs',
         forms.BooleanField(label=_("Include Children Forums"),
                            required=False))
Ejemplo n.º 28
0
class NewsletterForm(Form):
    name = forms.CharField(
        label=_("Newsletter Name"),
        help_text=
        _("Newsletter name will be used as message subject in e-mails sent to members."
          ),
        max_length=255,
        validators=[
            validate_sluggable(
                _("Newsletter name must contain alphanumeric characters."),
                _("Newsletter name is too long."))
        ])
    step_size = forms.IntegerField(
        label=_("Step Size"),
        help_text=
        _("Number of users that message will be sent to before forum refreshes page displaying sending progress."
          ),
        initial=300,
        min_value=1)
    content_html = forms.CharField(
        label=_("HTML Message"),
        help_text=_(
            "HTML message visible to members who can read HTML e-mails."),
        widget=forms.Textarea)
    content_plain = forms.CharField(
        label=_("Plain Text Message"),
        help_text=
        _("Alternative plain text message that will be visible to members that can't or dont want to read HTML e-mails."
          ),
        widget=forms.Textarea)
    ignore_subscriptions = forms.BooleanField(
        label=_("Ignore members preferences"),
        help_text=
        _("Change this option to yes if you want to send this newsletter to members that don't want to receive newsletters. This is good for emergencies."
          ),
        widget=YesNoSwitch,
        required=False)
    ranks = forms.ModelMultipleChoiceField(
        label=_("Limit to roles"),
        help_text=
        _("You can limit this newsletter only to members who have specific ranks. If you dont set any ranks, this newsletter will be sent to every user."
          ),
        widget=forms.CheckboxSelectMultiple,
        queryset=Rank.objects.order_by('name').all(),
        required=False)
Ejemplo n.º 29
0
    def type_fields(self):
        self.poll = self.thread.poll

        if self.poll:
            if self.request.acl.threads.can_edit_poll(self.forum, self.poll):
                self.edit_poll_form()
        else:
            if self.request.acl.threads.can_make_polls(self.forum):
                self.create_poll_form()

        if self.poll and self.request.acl.threads.can_delete_poll(
                self.forum, self.poll):
            self.add_field(
                'poll_delete',
                forms.BooleanField(label=_("Delete poll"), required=False))

        if self.request.acl.threads.can_change_prefix(self.forum):
            self.create_prefix_form()
Ejemplo n.º 30
0
class SubscriptionForm(forms.Form):
    subscribe = forms.BooleanField(label=_('Subscribe?'), required=False)
    name = forms.CharField(label=_('Name'), required=False)
    url = forms.URLField(label=_('URL'))
    category = forms.ChoiceField(label=_('Category'), required=False)

    def clean_url(self):
        url = self.cleaned_data['url']
        if (self.cleaned_data.get('subscribe', False)
                and self.user.feeds.filter(url=url).exists()):
            raise forms.ValidationError(
                _("You are already subscribed to this feed."))
        return url

    def clean_name(self):
        if (self.cleaned_data.get('subscribe', False)
                and not self.cleaned_data['name']):
            raise forms.ValidationError(_('This field is required.'))
        return self.cleaned_data['name']