Example #1
0
 def __init__(self, *args, **kwargs):
     self.product = kwargs.pop('product', None)
     super(PurchasedProductForm, self).__init__(*args, **kwargs)
     if not self.company:
         self.fields['company_name'] = CharField(label='Company Name')
         self.fields.keyOrder.insert(0, self.fields.keyOrder.pop())
     autofocus_input(self)
Example #2
0
    def __init__(self, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label="Name",
            max_length=255,
            required=True,
            widget=forms.TextInput(attrs={
                'placeholder': 'Full Name',
                'id': 'id_contact-name'
            }))

        # add location fields to form if this is a new contact
        if not self.instance.name:
            notes = self.fields.pop('notes')
            self.fields.update(LocationForm().fields)
            self.fields['city'].required = False
            self.fields['state'].required = False
            # move notes field to the end
            self.fields['notes'] = notes

        init_tags(self)

        if self.instance.user:
            self.fields['email'].widget.attrs['readonly'] = True
            self.fields['email'].help_text = 'This email address is ' \
                                             'maintained by the owner ' \
                                             'of the My.jobs email account ' \
                                             'and cannot be changed.'
        autofocus_input(self, 'name')
Example #3
0
    def __init__(self, *args, **kwargs):
        super(PartnerForm, self).__init__(*args, **kwargs)
        contacts = Contact.objects.filter(partner=kwargs['instance'],
                                          archived_on__isnull=True)
        choices = [(contact.id, contact.name) for contact in contacts]

        if kwargs['instance'].primary_contact:
            for choice in choices:
                if choice[0] == kwargs['instance'].primary_contact_id:
                    choices.insert(0, choices.pop(choices.index(choice)))

            if not kwargs['instance'].primary_contact:
                choices.insert(0, ('', "No Primary Contact"))
            else:
                choices.append(('', "No Primary Contact"))
        else:
            choices.insert(0, ('', "No Primary Contact"))

        self.fields['primary_contact'] = forms.ChoiceField(
            label="Primary Contact",
            required=False,
            help_text=
            'Denotes who the primary contact is for this organization.',
            initial=unicode(choices[0][0]),
            choices=choices)

        init_tags(self)
        autofocus_input(self, 'name')
Example #4
0
 def __init__(self, *args, **kwargs):
     self.product = kwargs.pop("product", None)
     super(PurchasedProductForm, self).__init__(*args, **kwargs)
     if not self.company:
         self.fields["company_name"] = CharField(label="Company Name")
         self.fields.keyOrder.insert(0, self.fields.keyOrder.pop())
     autofocus_input(self)
Example #5
0
    def __init__(self, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label="Name", max_length=255, required=True,
            widget=forms.TextInput(attrs={'placeholder': 'Full Name',
                                          'id': 'id_contact-name'}))

        # add location fields to form if this is a new contact
        if not self.instance.name:
            notes = self.fields.pop('notes')
            self.fields.update(LocationForm().fields)
            self.fields['city'].required = False
            self.fields['state'].required = False
            # move notes field to the end
            self.fields['notes'] = notes

        init_tags(self)

        if self.instance.user:
            self.fields['email'].widget.attrs['readonly'] = True
            self.fields['email'].help_text = 'This email address is ' \
                                             'maintained by the owner ' \
                                             'of the My.jobs email account ' \
                                             'and cannot be changed.'
        autofocus_input(self, 'name')
Example #6
0
 def __init__(self, *args, **kwargs):
     super(MilitaryServiceForm, self).__init__(*args, **kwargs)
     self.fields[
         'service_start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields[
         'service_end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)
Example #7
0
    def __init__(self, *args, **kwargs):
        super(PartnerForm, self).__init__(*args, **kwargs)
        contacts = Contact.objects.filter(partner=kwargs['instance'],
                                          archived_on__isnull=True)
        choices = [(contact.id, contact.name) for contact in contacts]

        if kwargs['instance'].primary_contact:
            for choice in choices:
                if choice[0] == kwargs['instance'].primary_contact_id:
                    choices.insert(0, choices.pop(choices.index(choice)))

            if not kwargs['instance'].primary_contact:
                choices.insert(0, ('', "No Primary Contact"))
            else:
                choices.append(('', "No Primary Contact"))
        else:
            choices.insert(0, ('', "No Primary Contact"))

        self.fields['primary_contact'] = forms.ChoiceField(
            label="Primary Contact", required=False,
            help_text='Denotes who the primary contact is for this organization.',
            initial=unicode(choices[0][0]),
            choices=choices)

        init_tags(self)
        autofocus_input(self, 'name')
Example #8
0
    def __init__(self, *args, **kwargs):
        super(SitePackageForm, self).__init__(*args, **kwargs)
        if not is_superuser_in_admin(self.request):
            # Limit a user's access to only sites they own.
            self.fields["sites"].queryset = self.request.user.get_sites()

            # Limit a user to only companies they have access to.
            self.fields["owner"].queryset = self.request.user.companies.all()
        autofocus_input(self)
Example #9
0
    def __init__(self, *args, **kwargs):
        super(SitePackageForm, self).__init__(*args, **kwargs)
        if not is_superuser_in_admin(self.request):
            # Limit a user's access to only sites they own.
            self.fields['sites'].queryset = self.request.user.get_sites()

            # Limit a user to only companies they have access to.
            self.fields['owner'].queryset = self.request.user.companies.all()
        autofocus_input(self)
Example #10
0
    def __init__(self, *args, **kwargs):
        super(ProductGroupingForm, self).__init__(*args, **kwargs)

        if not is_superuser_in_admin(self.request):
            kwargs = {"owner": self.company}
            self.fields["products"].queryset = self.fields["products"].queryset.filter(**kwargs)

            self.initial["owner"] = self.company
            self.fields["owner"].widget = HiddenInput()
        autofocus_input(self)
Example #11
0
    def __init__(self, *args, **kwargs):
        super(OfflinePurchaseForm, self).__init__(*args, **kwargs)

        self.products = Product.objects.filter(owner=self.company)

        # Create the Product list.
        for product in self.products:
            label = "{name}".format(name=product.name)
            self.fields[str(product.pk)] = IntegerField(label=label, initial=0, min_value=0)
        autofocus_input(self)
Example #12
0
 def __init__(self, *args, **kwargs):
     super(OfflinePurchaseRedemptionForm, self).__init__(*args, **kwargs)
     if not self.company:
         self.fields["company_name"] = CharField(label="Company Name")
         self.fields["address_line_one"] = CharField(label="Address Line One")
         self.fields["address_line_two"] = CharField(label="Address Line Two", required=False)
         self.fields["city"] = CharField(label="City")
         self.fields["state"] = CharField(label="State")
         self.fields["country"] = CharField(label="Country")
         self.fields["zipcode"] = CharField(label="Zip Code")
     autofocus_input(self)
Example #13
0
    def __init__(self, *args, **kwargs):
        super(ProductGroupingForm, self).__init__(*args, **kwargs)

        if not is_superuser_in_admin(self.request):
            kwargs = {'owner': self.company}
            self.fields['products'].queryset = \
                self.fields['products'].queryset.filter(**kwargs)

            self.initial['owner'] = self.company
            self.fields['owner'].widget = HiddenInput()
        autofocus_input(self)
Example #14
0
    def __init__(self, *args, **kwargs):
        """
        This form is used only to create a partner.

        Had to change self.fields into an OrderDict to preserve order then
        'append' to the new fields because new fields need to be first.

        """
        self.user = kwargs.pop('user', '')
        super(NewPartnerForm, self).__init__(*args, **kwargs)

        # add location fields to form if this is a new contact
        if not self.instance.name:
            notes = self.fields.pop('notes')
            self.fields.update(LocationForm().fields)
            self.fields['city'].required = False
            self.fields['state'].required = False
            # move notes field to the end
            self.fields['notes'] = notes

        for field in self.fields.itervalues():
            # primary contact information isn't required to create a partner
            field.required = False
        model_fields = SortedDict(self.fields)

        new_fields = {
            'partnername': forms.CharField(
                label="Partner Organization", max_length=255, required=True,
                help_text="Name of the Organization",
                widget=forms.TextInput(
                    attrs={'placeholder': 'Partner Organization',
                           'id': 'id_partner-partnername'})),
            'partnersource': forms.CharField(
                label="Source", max_length=255, required=False,
                help_text="Website, event, or other source where you found the partner",
                widget=forms.TextInput(
                    attrs={'placeholder': 'Source',
                           'id': 'id_partner-partnersource'})),
            'partnerurl': forms.URLField(
                label="URL", max_length=255, required=False,
                help_text="Full url. ie http://partnerorganization.org",
                widget=forms.TextInput(attrs={'placeholder': 'URL',
                                              'id': 'id_partner-partnerurl'})),
            'partner-tags': forms.CharField(
                label='Tags', max_length=255, required=False,
                help_text="ie 'Disability', 'veteran-outreach', etc. Separate tags with a comma.",
                widget=forms.TextInput(attrs={'id': 'p-tags',
                                              'placeholder': 'Tags'}))
        }

        ordered_fields = SortedDict(new_fields)
        ordered_fields.update(model_fields)
        self.fields = ordered_fields
        autofocus_input(self, 'partnername')
Example #15
0
    def __init__(self, *args, **kwargs):
        choices = partner_email_choices(kwargs.pop('partner', None))
        super(PartnerSavedSearchForm, self).__init__(*args, **kwargs)
        self.instance.changed_data = self.changed_data
        self.instance.request = self.request
        self.fields["email"] = ChoiceField(
            widget=Select(),
            choices=choices,
            initial=choices[0][0],
            label="Send Results to",
            help_text="If a contact does not have an email they will "
            "not show up on this list.")
        self.fields["notes"].label = "Notes and Comments"
        self.fields["partner_message"].label = "Message for Contact"
        self.fields["url_extras"].label = "Source Codes & Campaigns"
        if self.instance.id and self.instance.tags:
            tag_names = ",".join(
                [tag.name for tag in self.instance.tags.all()])
            self.initial['tags'] = tag_names
        self.fields['tags'] = CharField(label='Tags',
                                        max_length=255,
                                        required=False,
                                        widget=TextInput(attrs={
                                            'id': 'p-tags',
                                            'placeholder': 'Tags'
                                        }))
        self.initial['text_only'] = self.instance.text_only

        if self.instance and self.instance.pk:
            # If it's an edit make the email recipient unchangeable (for
            # compliance purposes).
            self.fields['email'].widget.attrs['disabled'] = True

            # Disallow modifying the activation status of a saved search if
            # ALL of the following are true:
            # - The current instance has a value stored in unsubscriber
            # - The value in unsubscriber is an email address used by the
            #   recipient
            # - The editor is not the recipient
            if all([
                    self.instance.unsubscriber,
                    self.instance.user == User.objects.get_email_owner(
                        self.instance.unsubscriber),
                    self.instance.user != self.request.user
            ]):
                self.fields['is_active'].widget.attrs['disabled'] = True

        initial = kwargs.get("instance")
        feed_args = {"widget": HiddenInput()}
        if initial:
            feed_args["initial"] = initial.feed
        self.fields["feed"] = URLField(**feed_args)
        autofocus_input(self, 'url')
Example #16
0
    def __init__(self, *args, **kwargs):
        super(OfflinePurchaseForm, self).__init__(*args, **kwargs)

        self.products = Product.objects.filter(owner=self.company)

        # Create the Product list.
        for product in self.products:
            label = '{name}'.format(name=product.name)
            self.fields[str(product.pk)] = IntegerField(label=label,
                                                        initial=0,
                                                        min_value=0)
        autofocus_input(self)
Example #17
0
    def __init__(self, *args, **kwargs):
        super(SavedSearchForm, self).__init__(*args, **kwargs)
        choices = make_choices(self.user)
        self.fields["email"] = ChoiceField(widget=Select(), choices=choices,
                                           initial=choices[0][0])

        initial = kwargs.get("instance")
        # TODO: Rework text_only overrides when this is promoted to SavedSearch
        text_only_kwargs = {'widget': HiddenInput(),
                            'initial': initial.text_only if initial else False,
                            'required': False}
        self.fields["text_only"] = BooleanField(**text_only_kwargs)
        autofocus_input(self, 'url')
Example #18
0
 def __init__(self, *args, **kwargs):
     super(OfflinePurchaseRedemptionForm, self).__init__(*args, **kwargs)
     if not self.company:
         self.fields['company_name'] = CharField(label='Company Name')
         self.fields['address_line_one'] = CharField(
             label='Address Line One')
         self.fields['address_line_two'] = CharField(
             label='Address Line Two', required=False)
         self.fields['city'] = CharField(label='City')
         self.fields['state'] = CharField(label='State')
         self.fields['country'] = CharField(label='Country')
         self.fields['zipcode'] = CharField(label='Zip Code')
     autofocus_input(self)
Example #19
0
 def __init__(self, *args, **kwargs):
     request = kwargs.pop('request')
     company = get_company_or_404(request)
     self.sites = SeoSite.objects.filter(canonical_company=company)
     super(EmailDomainForm, self).__init__(*args, **kwargs)
     for site in self.sites:
         field_kwargs = {
             'widget': forms.Select(),
             'choices': site.email_domain_choices(),
             'initial': site.email_domain,
             'label': 'Email Domain For %s' % site.domain,
         }
         self.fields[str(site.pk)] = forms.ChoiceField(**field_kwargs)
     autofocus_input(self)
Example #20
0
    def __init__(self, *args, **kwargs):
        super(CompanyProfileForm, self).__init__(*args, **kwargs)
        if "MarketPlace" not in self.instance.company.enabled_access:
            self.fields.pop("authorize_net_login", None)
            self.fields.pop("authorize_net_transaction_key", None)

        self.fields["company_name"] = CharField(initial=self.instance.company.name, label="Company Name")
        self.fields.keyOrder.insert(0, self.fields.keyOrder.pop())

        # companies pulled from content acquisition should be read-only
        if not self.instance.company.user_created:
            self.fields["company_name"].widget.attrs["readonly"] = True
            self.fields["description"].widget.attrs["readonly"] = True
        autofocus_input(self)
Example #21
0
    def __init__(self, *args, **kwargs):
        super(CompanyProfileForm, self).__init__(*args, **kwargs)
        if 'MarketPlace' not in self.instance.company.enabled_access:
            self.fields.pop('authorize_net_login', None)
            self.fields.pop('authorize_net_transaction_key', None)

        self.fields['company_name'] = CharField(
            initial=self.instance.company.name, label='Company Name')
        self.fields.keyOrder.insert(0, self.fields.keyOrder.pop())

        # companies pulled from content acquisition should be read-only
        if not self.instance.company.user_created:
            self.fields['company_name'].widget.attrs['readonly'] = True
            self.fields['description'].widget.attrs['readonly'] = True
        autofocus_input(self)
Example #22
0
    def __init__(self, *args, **kwargs):
        super(SavedSearchForm, self).__init__(*args, **kwargs)
        choices = make_choices(self.user)
        self.fields["email"] = ChoiceField(widget=Select(),
                                           choices=choices,
                                           initial=choices[0][0])

        initial = kwargs.get("instance")
        # TODO: Rework text_only overrides when this is promoted to SavedSearch
        text_only_kwargs = {
            'widget': HiddenInput(),
            'initial': initial.text_only if initial else False,
            'required': False
        }
        self.fields["text_only"] = BooleanField(**text_only_kwargs)
        autofocus_input(self, 'url')
Example #23
0
    def __init__(self, *args, **kwargs):
        choices = partner_email_choices(kwargs.pop('partner', None))
        super(PartnerSavedSearchForm, self).__init__(*args, **kwargs)
        self.instance.changed_data = self.changed_data
        self.instance.request = self.request
        self.fields["email"] = ChoiceField(
            widget=Select(), choices=choices,
            initial=choices[0][0], label="Send Results to",
            help_text="If a contact does not have an email they will "
                      "not show up on this list.")
        self.fields["notes"].label = "Notes and Comments"
        self.fields["partner_message"].label = "Message for Contact"
        self.fields["url_extras"].label = "Source Codes & Campaigns"
        if self.instance.id and self.instance.tags:
            tag_names = ",".join([tag.name for tag in self.instance.tags.all()])
            self.initial['tags'] = tag_names
        self.fields['tags'] = CharField(
            label='Tags', max_length=255, required=False,
            widget=TextInput(attrs={'id': 'p-tags', 'placeholder': 'Tags'})
        )
        self.initial['text_only'] = self.instance.text_only

        if self.instance and self.instance.pk:
            # If it's an edit make the email recipient unchangeable (for
            # compliance purposes).
            self.fields['email'].widget.attrs['disabled'] = True

            # Disallow modifying the activation status of a saved search if
            # ALL of the following are true:
            # - The current instance has a value stored in unsubscriber
            # - The value in unsubscriber is an email address used by the
            #   recipient
            # - The editor is not the recipient
            if all([self.instance.unsubscriber,
                    self.instance.user == User.objects.get_email_owner(
                        self.instance.unsubscriber),
                    self.instance.user != self.request.user]):
                self.fields['is_active'].widget.attrs['disabled'] = True

        initial = kwargs.get("instance")
        feed_args = {"widget": HiddenInput()}
        if initial:
            feed_args["initial"] = initial.feed
        self.fields["feed"] = URLField(**feed_args)
        autofocus_input(self, 'url')
Example #24
0
    def __init__(self, *args, **kwargs):
        partner = None
        if 'partner' in kwargs:
            partner = kwargs.pop('partner')
        super(ContactRecordForm, self).__init__(*args, **kwargs)
        self.fields['contact'].required = True
        if not hasattr(self.instance, 'contact'):
            self.fields['contact'].required = False

        instance = kwargs.get('instance')
        if partner:
            self.fields["contact"].queryset = Contact.objects.filter(
                partner=partner, archived_on__isnull=True)

        if not instance or instance.contact_type != 'pssemail':
            # Remove Partner Saved Search from the list of valid
            # contact type choices.
            contact_type_choices = self.fields["contact_type"].choices
            pssemail = ('pssemail', 'Partner Saved Search Email')
            if pssemail in contact_type_choices:
                contact_type_choices.remove(pssemail)
                self.fields["contact_type"].choices = contact_type_choices

        # If there are attachments create a checkbox option to delete them.
        if instance and partner:
            attachments = PRMAttachment.objects.filter(contact_record=instance)
            if attachments:
                choices = [
                    (a.pk,
                     get_attachment_link(partner.id, a.id,
                                         a.attachment.name.split("/")[-1]))
                    for a in attachments
                ]
                self.fields["attach_delete"] = forms.MultipleChoiceField(
                    required=False,
                    choices=choices,
                    label="Delete Files",
                    widget=forms.CheckboxSelectMultiple)
        init_tags(self)

        # mark contact type specific fields as required
        for field in ['contact_email', 'contact_phone', 'location', 'job_id']:
            self.fields[field].label += " *"
        autofocus_input(self, "notes" if self.instance.pk else "contact_type")
Example #25
0
    def __init__(self, *args, **kwargs):
        super(ProductForm, self).__init__(*args, **kwargs)
        if not is_superuser_in_admin(self.request):
            # Update querysets based on what the user should have
            # access to.
            self.fields["owner"].widget = HiddenInput()
            self.initial["owner"] = self.company

            packages = Package.objects.user_available()
            packages = packages.filter_company([self.company])
            self.fields["package"].queryset = packages
            # remove "------" option from select box
            self.fields["package"].empty_label = None

        if self.instance.pk and self.instance.num_jobs_allowed != 0:
            self.initial["job_limit"] = "specific"

        profile = get_object_or_none(CompanyProfile, company=self.company)
        if not profile or not (profile.authorize_net_login and profile.authorize_net_transaction_key):
            if is_superuser_in_admin(self.request):
                # Superusers should know better than to break things
                self.fields["cost"].help_text = (
                    "This member needs to "
                    "have added Authorize.net "
                    "account information "
                    "before we can safely "
                    "charge for posting. If "
                    "that hasn't been added, "
                    "bad things may happen."
                )
            else:
                self.fields["cost"].help_text = (
                    "You cannot charge for "
                    "jobs until you "
                    "<a href=%s>add your "
                    "Authorize.net account "
                    "information</a>." % reverse_lazy("companyprofile_add")
                )
                self.initial["cost"] = 0
                self.fields["cost"].widget.attrs["readonly"] = True
                setattr(self, "no_payment_info", True)
        autofocus_input(self)
Example #26
0
    def __init__(self, *args, **kwargs):
        super(BaseJobForm, self).__init__(*args, **kwargs)

        # Set the starting apply option.
        if self.instance and self.instance.apply_info:
            self.initial["apply_type"] = "instructions"
        else:
            # convert apply_link to email
            if self.instance.apply_link.startswith("mailto:"):
                self.initial["apply_email"] = self.instance.apply_link.split("mailto:")[1]
                self.initial["apply_type"] = "email"
            else:
                # This works because apply_email is actually a link
                # that uses mailto:
                self.initial["apply_type"] = "link"

        if not is_superuser_in_admin(self.request):
            # Remove the option to set the company.
            self.fields["owner"].widget = HiddenInput()
            self.initial["owner"] = self.company
        autofocus_input(self, "title")
Example #27
0
    def __init__(self, *args, **kwargs):
        super(ProductForm, self).__init__(*args, **kwargs)
        if not is_superuser_in_admin(self.request):
            # Update querysets based on what the user should have
            # access to.
            self.fields['owner'].widget = HiddenInput()
            self.initial['owner'] = self.company

            packages = Package.objects.user_available()
            packages = packages.filter_company([self.company])
            self.fields['package'].queryset = packages
            # remove "------" option from select box
            self.fields['package'].empty_label = None

        if self.instance.pk and self.instance.num_jobs_allowed != 0:
            self.initial['job_limit'] = 'specific'

        profile = get_object_or_none(CompanyProfile, company=self.company)
        if (not profile or not (profile.authorize_net_login
                                and profile.authorize_net_transaction_key)):
            if is_superuser_in_admin(self.request):
                # Superusers should know better than to break things
                self.fields["cost"].help_text = ("This member needs to "
                                                 "have added Authorize.net "
                                                 "account information "
                                                 "before we can safely "
                                                 "charge for posting. If "
                                                 "that hasn't been added, "
                                                 "bad things may happen.")
            else:
                self.fields['cost'].help_text = (
                    'You cannot charge for '
                    'jobs until you '
                    '<a href=%s>add your '
                    'Authorize.net account '
                    'information</a>.' % reverse_lazy('companyprofile_add'))
                self.initial['cost'] = 0
                self.fields['cost'].widget.attrs['readonly'] = True
                setattr(self, 'no_payment_info', True)
        autofocus_input(self)
Example #28
0
    def __init__(self, *args, **kwargs):
        super(BaseJobForm, self).__init__(*args, **kwargs)

        # Set the starting apply option.
        if self.instance and self.instance.apply_info:
            self.initial['apply_type'] = 'instructions'
        else:
            # convert apply_link to email
            if self.instance.apply_link.startswith("mailto:"):
                self.initial['apply_email'] = self.instance.apply_link.split(
                    'mailto:')[1]
                self.initial['apply_type'] = 'email'
            else:
                # This works because apply_email is actually a link
                # that uses mailto:
                self.initial['apply_type'] = 'link'

        if not is_superuser_in_admin(self.request):
            # Remove the option to set the company.
            self.fields['owner'].widget = HiddenInput()
            self.initial['owner'] = self.company
        autofocus_input(self, 'title')
Example #29
0
    def __init__(self, *args, **kwargs):
        partner = None
        if 'partner' in kwargs:
            partner = kwargs.pop('partner')
        super(ContactRecordForm, self).__init__(*args, **kwargs)
        self.fields['contact'].required = True
        if not hasattr(self.instance, 'contact'):
            self.fields['contact'].required = False

        instance = kwargs.get('instance')
        if partner:
            self.fields["contact"].queryset = Contact.objects.filter(
                partner=partner, archived_on__isnull=True)

        if not instance or instance.contact_type != 'pssemail':
            # Remove Partner Saved Search from the list of valid
            # contact type choices.
            contact_type_choices = self.fields["contact_type"].choices
            pssemail = ('pssemail', 'Partner Saved Search Email')
            if pssemail in contact_type_choices:
                contact_type_choices.remove(pssemail)
                self.fields["contact_type"].choices = contact_type_choices

        # If there are attachments create a checkbox option to delete them.
        if instance and partner:
            attachments = PRMAttachment.objects.filter(contact_record=instance)
            if attachments:
                choices = [(a.pk, get_attachment_link(partner.id, a.id,
                            a.attachment.name.split("/")[-1]))
                           for a in attachments]
                self.fields["attach_delete"] = forms.MultipleChoiceField(
                    required=False, choices=choices, label="Delete Files",
                    widget=forms.CheckboxSelectMultiple)
        init_tags(self)

        # mark contact type specific fields as required
        for field in ['contact_email', 'contact_phone', 'location', 'job_id']:
            self.fields[field].label += " *"
        autofocus_input(self, "notes" if self.instance.pk else "contact_type")
Example #30
0
 def __init__(self, *args, **kwargs):
     super(SecondaryEmailForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #31
0
 def __init__(self, *args, **kwargs):
     super(EducationForm, self).__init__(*args, **kwargs)
     self.fields['degree_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)
Example #32
0
 def __init__(self, *args, **kwargs):
     super(CustomSetPasswordForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #33
0
 def __init__(self, *args, **kwargs):
     super(BlockForm, self).__init__(*args, **kwargs)
     self.fields['template'].initial = models.raw_base_template(self.Meta.model)
     self.fields['head'].initial = models.raw_base_head(self.Meta.model)
     autofocus_input(self)
Example #34
0
 def __init__(self, *args, **kwargs):
     super(LocationForm, self).__init__(*args, **kwargs)
     autofocus_input(self, 'address_line_one')
Example #35
0
 def __init__(self, request=None, *args, **kwargs):
     super(CustomAuthForm, self).__init__(request, *args, **kwargs)
     autofocus_input(self, 'username')
Example #36
0
 def __init__(self, *args, **kwargs):
     super(CompanyAccessRequestApprovalForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #37
0
 def __init__(self, *args, **kwargs):
     super(AddressForm, self).__init__(*args, **kwargs)
     autofocus_input(self, 'address_line_one')
Example #38
0
 def __init__(self, *args, **kwargs):
     super(MilitaryServiceForm, self).__init__(*args, **kwargs)
     self.fields['service_start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['service_end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)
Example #39
0
 def __init__(self, *args, **kwargs):
     super(EducationForm, self).__init__(*args, **kwargs)
     self.fields['degree_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)
Example #40
0
 def __init__(self, *args, **kwargs):
     super(NameForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #41
0
 def __init__(self, *args, **kwargs):
     super(EmploymentHistoryForm, self).__init__(*args, **kwargs)
     self.fields['start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)
Example #42
0
 def __init__(self, *args, **kwargs):
     super(NameForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #43
0
 def __init__(self, *args, **kwargs):
     super(CompanyAccessRequestApprovalForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #44
0
 def __init__(self, *args, **kwargs):
     super(BlockForm, self).__init__(*args, **kwargs)
     self.fields['template'].initial = models.raw_base_template(
         self.Meta.model)
     self.fields['head'].initial = models.raw_base_head(self.Meta.model)
     autofocus_input(self)
Example #45
0
 def __init__(self, *args, **kwargs):
     super(SecondaryEmailForm, self).__init__(*args, **kwargs)
     autofocus_input(self)
Example #46
0
    def __init__(self, *args, **kwargs):
        """
        This form is used only to create a partner.

        Had to change self.fields into an OrderDict to preserve order then
        'append' to the new fields because new fields need to be first.

        """
        self.user = kwargs.pop('user', '')
        super(NewPartnerForm, self).__init__(*args, **kwargs)

        # add location fields to form if this is a new contact
        if not self.instance.name:
            notes = self.fields.pop('notes')
            self.fields.update(LocationForm().fields)
            self.fields['city'].required = False
            self.fields['state'].required = False
            # move notes field to the end
            self.fields['notes'] = notes

        for field in self.fields.itervalues():
            # primary contact information isn't required to create a partner
            field.required = False
        model_fields = SortedDict(self.fields)

        new_fields = {
            'partnername':
            forms.CharField(label="Partner Organization",
                            max_length=255,
                            required=True,
                            help_text="Name of the Organization",
                            widget=forms.TextInput(
                                attrs={
                                    'placeholder': 'Partner Organization',
                                    'id': 'id_partner-partnername'
                                })),
            'partnersource':
            forms.CharField(
                label="Source",
                max_length=255,
                required=False,
                help_text=
                "Website, event, or other source where you found the partner",
                widget=forms.TextInput(attrs={
                    'placeholder': 'Source',
                    'id': 'id_partner-partnersource'
                })),
            'partnerurl':
            forms.URLField(
                label="URL",
                max_length=255,
                required=False,
                help_text="Full url. ie http://partnerorganization.org",
                widget=forms.TextInput(attrs={
                    'placeholder': 'URL',
                    'id': 'id_partner-partnerurl'
                })),
            'partner-tags':
            forms.CharField(
                label='Tags',
                max_length=255,
                required=False,
                help_text=
                "ie 'Disability', 'veteran-outreach', etc. Separate tags with a comma.",
                widget=forms.TextInput(attrs={
                    'id': 'p-tags',
                    'placeholder': 'Tags'
                }))
        }

        ordered_fields = SortedDict(new_fields)
        ordered_fields.update(model_fields)
        self.fields = ordered_fields
        autofocus_input(self, 'partnername')
Example #47
0
 def __init__(self, *args, **kwargs):
     super(EmploymentHistoryForm, self).__init__(*args, **kwargs)
     self.fields['start_date'].input_formats = settings.DATE_INPUT_FORMATS
     self.fields['end_date'].input_formats = settings.DATE_INPUT_FORMATS
     autofocus_input(self)