예제 #1
0
파일: forms.py 프로젝트: luzfcb/sosmypc
class RegistrationForm(forms.Form, UserCreationForm):
    username = forms.CharField(max_length=30, required=True, label='Login')
    email = forms.EmailField(label="E-mail", required=True)
    #senha = forms.CharField(widget=forms.PasswordInput,label='Senha')
    #confirma_senha = forms.CharField(widget=forms.PasswordInput, label="Confirmar senha")

    nome = forms.CharField(required=True, label='Nome Completo')
    cep = forms.IntegerField(max_value=99999999, required=True, label='CEP')
    #tipo_logradouro = forms.CharField(required=True,label='Tipo')
    logradouro = forms.CharField(required=True, label='Logradouro')
    numero = forms.CharField(required=True, label='Número')
    bairro = forms.CharField(required=True, label='Bairro')
    cidade = forms.CharField(required=True, label='Cidade')
    estado = forms.CharField(required=True, label='UF')

    #last_name = forms.CharField(required=True, label='Último nome')
    #gender = forms.ChoiceField(choices=((None, ''), ('F', 'Feminino'), ('M', 'Masculino'), ('O', 'Outro')),label='Gênero',required=False)
    profissional = forms.BooleanField(required=False,
                                      label='Sou profissional.')
    agree_toc = forms.BooleanField(
        required=True, label='Eu aceito os termos e condições de uso.')

    layout = Layout(
        Fieldset('Cadastrar em SOS my PC', 'username', 'email',
                 Row('password1', 'password2')),
        Fieldset(
            'Dados Pessoais',
            'nome',
            Row(
                Span2('cep'),  # Span2('tipo_logradouro'),
                Span8('logradouro'),
                Span2('numero')),
            Row(Span5('bairro'), Span5('cidade'), Span2('estado'))),
        'profissional',
        'agree_toc')
예제 #2
0
class ClientForm(forms.ModelForm):

    representative = forms.ModelChoiceField(queryset=Client.objects.filter(is_representative=True), required=False,
                                            label="Representante (Matriz ou Filial)", )

    class Meta:
        model = Client
        fields = (
            'cdalterdata',
            'name',
            'phone',
            'cpf_cnpj',
            'email',
            'cep',
            'logradouro',
            'numero',
            'bairro',
            'cidade',
            'estado',
            'representative',
            'last_search',
        )
        exclude = ('is_representative', 'priority',)

    layout = Layout(
        Fieldset("Cliente",
                 Row(Span3('cdalterdata'), Span9('name'), ),
                 Row(Span12('representative'), ),
                 Row(Span4('phone'), Span8('cpf_cnpj')),
                 Row(Span9('email'), Span3('last_search'), ),
                 ),
        Fieldset('Endereço',
                 Row(Span2('cep'), Span8('logradouro'), Span2('numero')),
                 Row(Span5('bairro'), Span5('cidade'), Span2('estado')))
        )
예제 #3
0
class RepresentativeForm(forms.ModelForm):

    class Meta:
        model = Client
        fields = (
            'cdalterdata',
            'name',
            'phone',
            'cpf_cnpj',
            'email',
            'cep',
            'logradouro',
            'numero',
            'bairro',
            'cidade',
            'estado',
        )
        exclude = ('representative', 'is_representative', 'last_search', 'priority',)

    layout = Layout(
        Fieldset("Filial ou Representação",
                 Row(Span3('cdalterdata'), Span9('name'), ),
                 Row(Span4('phone'), Span8('cpf_cnpj')),
                 Row(Span12('email'), ),
                 ),
        Fieldset('Endereço',
                 Row(Span2('cep'), Span8('logradouro'), Span2('numero')),
                 Row(Span5('bairro'), Span5('cidade'), Span2('estado')))
        )
예제 #4
0
class CheckoutForm(forms.Form):
    first_name = forms.CharField()
    last_name = forms.CharField()
    email = forms.EmailField()
    phone = forms.CharField()
    country = forms.ChoiceField(choices=COUNTRY_CHOICES)
    city = forms.CharField()
    post_code = forms.IntegerField()
    address = forms.CharField()
    additional_info = forms.CharField(widget=forms.Textarea)
    card_type = forms.ChoiceField(choices=(('V', 'Visa'), ('M', 'MasterCard'),
                                           ('P', 'Paypal')),
                                  widget=forms.RadioSelect)
    card_holder = forms.CharField(label="Name on card")
    card_number = forms.CharField(label="Card number")
    card_ccv2 = forms.IntegerField(label="CVV2")
    card_exp_month = forms.ChoiceField(
        choices=((1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'),
                 (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'),
                 (9, 'September'), (10, 'October'), (11, 'November'),
                 (12, 'December')))
    card_exp_year = forms.IntegerField(label="Year")

    layout = Layout(
        Row('first_name', 'last_name'), Row('email', 'phone'),
        Row(Span5('country'), Span5('city'), Span2('post_code')), 'address',
        'additional_info',
        Fieldset(
            'Card Details',
            Row(
                Column('card_type', span_columns=4),
                Column('card_holder',
                       Row(Span10('card_number'), Span2('card_ccv2')),
                       Row('card_exp_month', 'card_exp_year'),
                       span_columns=8))))

    template = Template("""
    {% form %}
        {% part form.first_name prefix %}<i class="material-icons prefix">account_box</i>{% endpart %}
        {% part form.last_name prefix %}<i class="material-icons prefix">account_box</i>{% endpart %}
        {% part form.email prefix %}<i class="material-icons prefix">email</i>{% endpart %}
        {% part form.phone prefix %}<i class="material-icons prefix">call</i>{% endpart %}
        {% part form.card_type label %}{% endpart %}
    {% endform %}
    """)

    buttons = Template("""
        <button class="btn btn-primary pull-right" type="submit">Submit request</button>
    """)

    title = "Checkout form"

    css = """
예제 #5
0
class ShareholderForm(forms.ModelForm):
    layout = Layout(
        'bank',
        Fieldset(
            "Shareholders",
            Row(Span4('shareholder'), Span2('share'),
                Span4('ultimate_country_name'), Span2('ultimate_country_id')),
            Row(Span6('category'), Span6('is_ultimate'))))

    class Meta:
        model = Shareholder
        fields = '__all__'
예제 #6
0
class QuestionForm(ModelForm):

    choices = InlineFormSetField(parent_model=Question,
                                 model=Choice,
                                 fields=['choice_text'],
                                 extra=2)

    class Meta:
        model = Question
        fields = ['question_text', 'nature_of_emergency', 'preferred_choice']

    layout = Layout(Row(Span2('question_text')),
                    Row(Span2('preferred_choice')),
                    Row(Span2('nature_of_emergency')), Row(Span4('choices')))
예제 #7
0
class PersonForm(forms.ModelForm):
    related_person = forms.ModelMultipleChoiceField(label='Pessoa Relacionada',
                                                    required=False,
                                                    queryset=Person.objects.all().order_by('name'),
                                                    )

    class Meta:
        model = Person
        fields = (
            'name',
            'name_fantasy',
            'phone',
            'cpf_cnpj',
            'email',
            'nascimento',
            'rg',
            'cep',
            'logradouro',
            'complemento',
            'numero',
            'bairro',
            'cidade',
            'estado',
            'category_person',
            'related_person',

        )
        exclude = ('priority', 'nascimento')

    layout = Layout(
        Fieldset("Pessoa",
                 Row(Span8('name'), Span4('name_fantasy'), ),
                 Row(Span4('phone'), Span4('cpf_cnpj'), Span4('rg')),
                 Row(Span12('email'), ),
                 ),

        Fieldset("Categorias da Pessoa",
                 Row(Span12('category_person'),)
                 ),

        Fieldset("Pessoa Relacionada",
                 Row(Span12('related_person'), )
                 ),

        Fieldset('Endereço',
                 Row(Span2('cep'), Span6('logradouro'), Span2('complemento'), Span2('numero')),
                 Row(Span5('bairro'), Span5('cidade'), Span2('estado')))
        )
예제 #8
0
class NewShipmentView(LayoutMixin, CreateView):
    title = "New Shipment"
    model = Shipment
    layout = Layout(
        Row('first_name', 'last_name', 'email'),
        Row('phone'),
        Fieldset('Address', Row(Span7('address'), Span5('zipcode')),
                 Row(Span5('city'), Span2('state'), Span5('country'))),
    )
예제 #9
0
파일: forms.py 프로젝트: sjl421/cookbook-2
class PatientForm(forms.ModelForm):
    layout = Layout(
        Row(Span2('patient_id'), 'age', 'sex'),
        Row('weight', 'height'),
        'comment',
    )

    class Meta:
        model = models.Patient
        fields = '__all__'
예제 #10
0
class NewShipmentView(LayoutMixin,
                      extra_views.NamedFormsetsMixin,
                      extra_views.CreateWithInlinesView):
    title = "New Shipment"
    model = Shipment
    layout = Layout(
        Row('first_name', 'last_name', 'email'),
        Row('phone'),
        Fieldset('Address',
                 Row(Span7('address'), Span5('zipcode')),
                 Row(Span5('city'), Span2('state'), Span5('country'))),
        Inline('Shipment Items', ItemInline),
    )
예제 #11
0
class ExecutiveForm(forms.ModelForm):
    gender = forms.ChoiceField(
        choices=Executive.GENDER,
        # label='Bank Category',
        widget=forms.RadioSelect)
    layout = Layout(
        Row(Span6('bank'), Span6('period')),
        Fieldset("Bank Executives",
                 Row(Span6('name'), Span2('gender'), Span4('photo')),
                 Row(Span6('title'), Span6('report_to')), 'is_current'))

    class Meta:
        model = Executive
        fields = '__all__'
예제 #12
0
class StartView(StartFlowMixin, generic.UpdateView):
    form_class = ShipmentForm

    layout = Layout(
        Row('shipment_no'),
        Fieldset('Customer Details', Row('first_name', 'last_name', 'email'),
                 Row('phone')),
        Fieldset('Address', Row(Span7('address'), Span5('zipcode')),
                 Row(Span5('city'), Span2('state'), Span5('country'))),
        'items',
    )

    def get_object(self):
        return self.activation.process.shipment

    def activation_done(self, form):
        shipment = form.save()
        self.activation.process.shipment = shipment
        super(StartView, self).activation_done(form)
예제 #13
0
class StartView(LayoutMixin, flow_views.StartViewMixin,
                extra_views.NamedFormsetsMixin,
                extra_views.CreateWithInlinesView):
    model = Shipment
    layout = Layout(
        Row('shipment_no'),
        Fieldset('Customer Details', Row('first_name', 'last_name', 'email'),
                 Row('phone')),
        Fieldset('Address', Row(Span7('address'), Span5('zipcode')),
                 Row(Span5('city'), Span2('state'), Span5('country'))),
        Inline('Shipment Items', ItemInline),
    )

    def activation_done(self, form, inlines):
        self.object = form.save()
        for formset in inlines:
            formset.save()

        self.activation.process.created_by = self.request.user
        self.activation.process.shipment = self.object
        self.activation.done()
예제 #14
0
class BankForm(forms.Form):
    branch_name = forms.CharField()
    """ Personal Details """
    person_title = forms.ChoiceField(choices=(('Mr', 'Mr.'), ('Mrs.', 'Mrs.'),
                                              ('Ms.', 'Ms.')),
                                     label='Title')
    full_name = forms.CharField()
    date_of_birth = forms.DateField()
    email = forms.EmailField()
    parent_name = forms.CharField(
        label='In case of a minor please provide details')
    nationality = forms.ChoiceField(choices=COUNTRY_CHOICES)
    mobile_no = forms.CharField()
    existing_bank_account = forms.CharField()
    partner_name = forms.CharField(label='Name of father/spouse')
    """ Residential address """
    flat_bulding = forms.CharField(label='Flat no. and bldg. name')
    road_no = forms.CharField(label='Road no./name')
    area_and_landmark = forms.CharField(label='Area and landmark')
    telephone_residence = forms.CharField()
    city = forms.CharField()
    office = forms.CharField()
    fax = forms.CharField()
    pin_code = forms.CharField()
    """ Mailing Address """
    mailing_company_details = forms.CharField(
        label="Company name and department/ Flat no. and bldg. name")
    mailing_road_no = forms.CharField(label='Road no./name')
    mailing_area_and_landmark = forms.CharField(label='Area and landmark')
    mailing_city = forms.CharField(label='City')
    mailing_mobile = forms.CharField(label='Mobile No.')
    mailing_telephone_residence = forms.CharField(label='Telephone Residence')
    mailing_office = forms.CharField(label='Office')
    mailing_fax = forms.CharField(label='Fax')
    mailing_pin_code = forms.CharField(label='Pin Code')
    mailing_email = forms.EmailField(label='E-mail')
    """ Details of Introduction by Existing Customer """
    introducer_name = forms.CharField(label='Customer Name')
    introducer_account_no = forms.CharField(label='Account No.')
    introducer_signature = forms.CharField(label="Introducer's signature")
    """ Account Details """
    account_type = forms.ChoiceField(choices=(('S', 'Savings'), ('C',
                                                                 'Current'),
                                              ('F', 'Fixed deposits')),
                                     label='Choice of account',
                                     widget=forms.RadioSelect)
    account_mode = forms.ChoiceField(choices=(('CS', 'Cash'), ('CQ', 'Cheque'),
                                              ('NF', 'NEFT')),
                                     label='Mode of funding',
                                     widget=forms.RadioSelect)
    account_amount = forms.FloatField(label='Amount')
    """ Details of Fixed Deposit """
    deposit_type = forms.ChoiceField(choices=(('O', 'Ordinary'),
                                              ('C', 'Cumulative')),
                                     label='Types of deposit',
                                     widget=forms.RadioSelect)
    deposit_mode = forms.ChoiceField(choices=(('CS', 'Cash'), ('CQ', 'Cheque'),
                                              ('NF', 'NEFT')),
                                     label='Mode of funding',
                                     widget=forms.RadioSelect)
    deposit_amount = forms.FloatField(label='Amount')
    deposit_no = forms.CharField(label='No. of deposits')
    deposit_individual_amount = forms.FloatField(
        label='Individual Deposit Amount')
    """ Personal Details """
    occupation = forms.ChoiceField(
        choices=(('NE', 'Non-executive'), ('HW', 'Housewife'), ('RT',
                                                                'Retired'),
                 ('ST', 'Student'), ('OT', 'Other'), ('UN', 'Unemployed')),
        widget=forms.RadioSelect)
    job_title = forms.CharField()
    department = forms.CharField()
    nature_of_business = forms.CharField()
    education = forms.ChoiceField(choices=(('UG', 'Under graduate'),
                                           ('GR', 'Graduate'), ('OT',
                                                                'Others')),
                                  widget=forms.RadioSelect)
    montly_income = forms.ChoiceField(choices=(('000', 'Zero Income'),
                                               ('L10', 'Less than $10,000'),
                                               ('G10', '$10,000+')),
                                      widget=forms.RadioSelect)
    martial_status = forms.ChoiceField(choices=(('M', 'Married'), ('S',
                                                                   'Single')),
                                       widget=forms.RadioSelect)
    spouse_name = forms.CharField()
    """ Other existing bank accounts, if any """
    other_account1 = forms.CharField(label='Name of the Bank / branch')
    other_account2 = forms.CharField(label='Name of the Bank / branch')
    """ Reason for Account opening """
    reason = forms.CharField(label="Please specify", widget=forms.Textarea)
    """ Terms And Conditions """
    terms_accepted = forms.BooleanField(
        label=
        "I/We confirm having read and understood the account rules of The Banking Corporation Limited"
        " ('the Bank'), and hereby agree to be bound by the terms and conditions and amendments governing the"
        " account(s) issued by the Bank from time-to-time.")

    layout = Layout(
        Fieldset("Please open an account at", 'branch_name'),
        Fieldset(
            "Personal Details (Sole/First Accountholder/Minor)",
            Row(Span2('person_title'), Span10('full_name')),
            Row(
                Column('date_of_birth', 'email', 'parent_name'),
                Column('nationality', Row('mobile_no',
                                          'existing_bank_account'),
                       'partner_name'))),
        Fieldset('Residential address', Row('flat_bulding', 'road_no'),
                 Row(Span10('area_and_landmark'), Span2('city')),
                 Row('telephone_residence', 'office', 'fax', 'pin_code')),
        Fieldset(
            "Mailing Address (If different from the First Accountholder's address)",
            'mailing_company_details',
            Row('mailing_road_no', 'mailing_area_and_landmark', 'mailing_city',
                'mailing_mobile'),
            Row('mailing_telephone_residence', 'mailing_office', 'mailing_fax',
                'mailing_pin_code'), 'mailing_email'),
        Fieldset(
            "Details of Introduction by Existing Customer (If applicable)",
            Row('introducer_name', 'introducer_account_no'),
            'introducer_signature'),
        Fieldset("Account Details", Row('account_type', 'account_mode'),
                 'account_amount'),
        Fieldset(
            "Details of Fixed Deposit", Row('deposit_type', 'deposit_mode'),
            Row(Span6('deposit_amount'), Span3('deposit_no'),
                Span3('deposit_individual_amount'))),
        Fieldset("Personal Details",
                 Row('occupation', 'education', 'montly_income'), 'job_title',
                 Row('department', 'nature_of_business'),
                 Row('martial_status', 'spouse_name')),
        Fieldset("Other existing bank accounts, if any",
                 Row('other_account1', 'other_account2')),
        Fieldset("Reason for Account opening", 'reason'),
        Fieldset("Terms And Conditions", 'terms_accepted'))

    template = Template("""
    {% form %}
        {% attr form.account_type 'group' class append %}inline{% endattr %}
        {% attr form.account_mode 'group' class append %}inline{% endattr %}
        {% attr form.deposit_type 'group' class append %}inline{% endattr %}
        {% attr form.deposit_mode 'group' class append %}inline{% endattr %}
        {% attr form.martial_status 'group' class append %}inline{% endattr %}
    {% endform %}
    """)

    buttons = Template("""
        <button class="btn btn-primary pull-right" type="submit">Save application</button>
    """)

    title = "Personal Bank Account Initial Application"

    css = """
    .section h5 {
        font-size: 1.2rem;
        padding-bottom: 0.2rem;
        border-bottom: 3px solid black;
    }
    """

    blockclass = "col s12 m12 l9 offset-l1"
예제 #15
0
class SubjectForm(forms.ModelForm):
    layout_subject_extended = Layout(
        Row('event'),
        Row('num_seats'),
        Fieldset('Personal Information', Row('given_name', 'name'),
                 Row('email', 'phone'), Row(Span2('post_code'), Span5('city')),
                 'address'),
    )
    layout_subject_base = Layout(
        Row('event'),
        Row('num_seats'),
        Fieldset(_('Personal Information'), Row('given_name', 'name'),
                 Row('email')),
    )
    layout = layout_subject_extended if settings.SUBJECT_CLASS == 'SubjectExtended' else layout_subject_base
    if settings.PRIVACY_NOTICE:
        layout.elements.append(Fieldset(_('_privacy'), Row('privacy')))

    def __init__(self, *args, **kwargs):
        super(SubjectForm, self).__init__(*args, **kwargs)
        instance = getattr(self, 'instance', None)
        # do not allow to modify the email and event for a registration
        if self.instance and instance.pk:
            self.fields['event'].disabled = True
            self.fields['email'].disabled = True
        elif settings.PRIVACY_NOTICE:
            self.fields['privacy'] = forms.BooleanField()
            self.fields['privacy'].label = _('confirmed')
            self.fields['privacy'].help_text = mark_safe(_('privacy_notice'))

    def clean_num_seats(self):
        instance = getattr(self, 'instance', None)
        if self.instance and instance.pk:
            ev = self.instance.event
        else:
            if not self.data['event']:
                return self.cleaned_data['num_seats']
            ev = self.cleaned_data['event']

        if self.cleaned_data['num_seats'] > ev.num_max_per_subject:
            raise ValidationError(ngettext_lazy(
                'max_seats_subj_exceeded_%(num_max)i',
                'max_seats_subj_exceeded_pl_%(num_max)i',
                ev.num_max_per_subject),
                                  code='invalid',
                                  params={'num_max': ev.num_max_per_subject})

        if self.instance and instance.pk:
            taken = ev.seats_taken

            # allow subject to decrease registration even if all seats are taken
            if taken >= ev.num_total_seats:
                if self.cleaned_data['num_seats'] > instance.num_seats:
                    raise ValidationError(_('no_seats_event'), code='invalid')
            # if not all seats are taken, allow subject to fill up seats up to num_total_seats
            elif taken - instance.num_seats + self.cleaned_data[
                    'num_seats'] > ev.num_total_seats:
                raise ValidationError(
                    ngettext_lazy('max_seats_exceeded_%(num_free)i',
                                  'max_seats_exceeded_pl_%(num_free)i',
                                  ev.num_total_seats - taken),
                    code='invalid',
                    params={'num_free': ev.num_total_seats - taken})

        else:
            taken = ev.seats_taken
            # it is not possible to create a registration when there are no more seats available
            if taken >= ev.num_total_seats:
                raise ValidationError(_('no_seats_event'), code='invalid')

            # it is not possible to exceed the number of available seats
            if taken + self.cleaned_data['num_seats'] > ev.num_total_seats:
                raise ValidationError(
                    ngettext_lazy('max_seats_exceeded_%(num_free)i',
                                  'max_seats_exceeded_pl_%(num_free)i',
                                  ev.num_total_seats - taken),
                    code='invalid',
                    params={'num_free': ev.num_total_seats - taken})

        assign_seats(ev, instance, self.cleaned_data['num_seats'])
        return self.cleaned_data['num_seats']

    class Meta:
        model = Subject
        fields = ['name', 'given_name', 'email', 'event', 'num_seats']
        if settings.SUBJECT_CLASS == 'SubjectExtended':
            fields.extend(['phone', 'address', 'post_code', 'city'])
        error_messages = {
            NON_FIELD_ERRORS: {
                'unique_together':
                "Es existiert bereits eine Registrierung für diese %(field_labels)s.",
            }
        }