Beispiel #1
0
 def __init__(self, *args, **kwargs):
     self.from_entity = kwargs.pop('from_entity', None)
     self.to_entity = kwargs.pop('to_entity', None)
     self.chat = kwargs.pop('chat', None)
     assert bool(self.from_entity and self.to_entity) != bool(
         self.from_entity and self.chat)
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     if (self.chat):
         self.helper.form_action = reverse(
             'im:chat_send',
             kwargs={
                 'chat_slug':
                 self.chat.get_slug(current_user=self.from_entity)
             })
     else:
         self.helper.form_action = reverse(
             'im_entity:user_send', kwargs={'slug': self.to_entity.slug})
     self.helper.form_class = 'form-vertical'
     self.helper.layout = Layout(
         InlineField('text', style="height: 55px"),
         Submit(
             'submit',
             pgettext_lazy(context=self.from_entity.get_gender(),
                           message='Send')),
     )
Beispiel #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['slug'].label = pgettext_lazy(
         context=self.instance.get_gender(), message='username (slug)')
     self.fields[
         'date_of_birth'].input_formats = django_settings.DATE_FIELD_FORMATS
     self.fields[
         'date_of_birth'].widget.format = django_settings.DEFAULT_DATE_FIELD_FORMAT
     self.fields['profile_picture'].widget.attrs['user'] = self.instance
     self.fields['profile_picture'].label = pgettext_lazy(
         context=self.instance.get_gender(),
         message='Update your profile picture')
     self.helper = FormHelperWithDefaults()
     # split into two columns
     field_names = list(self.fields.keys())
     self.helper.add_layout(
         Div(*[
             Row(*[Div(field, css_class='col-md-6') for field in pair])
             for pair in self.get_field_pairs()
         ]), )
     self.helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.instance.get_gender(),
                           message='Save Changes')))
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     for field in self._profile_model._meta.fields:
         if (field.name in self._profile_fields):
             self.fields[field.name] = field.formfield()
             self.fields[field.name].initial = getattr(self.instance.profile, field.name)
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(Submit('submit', pgettext_lazy(context=self.instance.get_gender(), message='Save Changes')))
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.instance.get_gender(),
                           message='Save Changes')))
Beispiel #5
0
 def helper(self):
     helper = FormHelperWithDefaults()
     helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.defaults['user'].get_gender(),
                           message='Add')))
     return helper
Beispiel #6
0
 def helper(self):
     helper = FormHelperWithDefaults()
     helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.user.get_gender(),
                           message='Change Password')))
     return helper
Beispiel #7
0
 def helper(self):
     helper = FormHelperWithDefaults()
     helper.form_class = 'form-inline'
     helper.form_action = reverse('accounts:change_email_privacy',
                                  kwargs={'pk': self.instance.id})
     helper.field_template = 'bootstrap3/layout/inline_field.html'
     helper.layout = Layout(InlineField('access', css_class='input-sm'), )
     return helper
Beispiel #8
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(Hidden('_form', 'password'))
     self.helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.user.get_gender(),
                           message='Change Password')))
Beispiel #9
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['slug'].label = _('New username')
     self.fields[
         'date_of_birth'].input_formats = django_settings.DATE_FIELD_FORMATS
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(
         Submit('submit',
                _('Create an account'),
                css_class='btn-lg btn-arrow-right'))
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     site = Site.objects.get_current()
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(
                 context=self.instance.user.get_gender(),
                 message='Activate your {site_name} account').format(
                     site_name=_(site.name))))
Beispiel #11
0
 def __init__(self, *args, **kwargs):
     self.user = kwargs.pop('user')
     super().__init__(*args, **kwargs)
     site = Site.objects.get_current()
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(
         Submit('submit',
                pgettext_lazy(
                    context=self.user.get_gender(),
                    message='Deactivate your {site_name} account').format(
                        site_name=_(site.name)),
                css_class='btn-danger'))
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     # split into two columns
     field_names = list(self.fields.keys())
     custom_field_names = ('gender_to_match', 'diet_match', 'smoking_status_match', 'marital_status_match')
     self.helper.add_layout(Div(*[
         Row(*[
             # a little hack that forces display of custom widgets
             Div(Field(field, template='%s/render.html') if (field in custom_field_names) else field, css_class='col-md-6')
             for field in pair])
         for pair in zip_longest(field_names[::2], field_names[1::2])
     ]))
     self.helper.add_input(Submit('submit', pgettext_lazy(context=self.instance.user.get_gender(), message='Save Changes')))
Beispiel #13
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.data = self.data.copy()
     if ('username' in self.data):
         self.data['username'] = self.data['username'].lower()
     self.fields['username'].label = _('Email or Username')
     self.helper = FormHelperWithDefaults()
     self.helper.add_layout(Div(
         'username',
         'password',
         Submit('submit', _('Login')),
         HTML('<a class="btn btn-link" href="{link}">{text}</a>'.format(
             link=reverse('accounts:password_reset'),
             text=_('Forgot your password?'),
         )),
     ))
Beispiel #14
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     if (self.defaults.get('sender')):
         del self.fields['sender_name']
         del self.fields['sender_email']
         self.helper.add_input(
             Submit(
                 'submit',
                 pgettext_lazy(context=self.defaults['sender'].get_gender(),
                               message='Send')))
     else:
         self.fields['sender_name'].required = True
         self.fields['sender_email'].required = True
         self.helper.add_layout(
             Row(
                 Div('sender_name', css_class='col-md-6'),
                 Div('sender_email', css_class='col-md-6'),
             ))
         self.helper.add_input(Submit('submit', _('Send')))
Beispiel #15
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     self.helper.error_text_inline = False
     # split into two columns
     custom_field_names = ('gender_to_match', 'diet_match',
                           'smoking_status_match',
                           'relationship_status_match')
     self.helper.add_layout(
         Div(*[
             Row(*[
                 # A little hack that forces display of custom widgets
                 Div(Field(field,
                           template='%s/speedy_match_custom_field.html') if
                     (field in custom_field_names) else field,
                     css_class='col-md-6') for field in pair
             ]) for pair in self.get_field_pairs()
         ]), )
     self.helper.add_input(
         Submit(
             'submit',
             pgettext_lazy(context=self.instance.user.get_gender(),
                           message='Save Changes')))
Beispiel #16
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelperWithDefaults()
     self.helper.add_input(Hidden('_form', 'password'))
     self.helper.add_input(Submit('submit', _('Change')))
Beispiel #17
0
 def helper(self):
     helper = FormHelperWithDefaults()
     helper.add_input(Submit('submit', _('Submit')))
     return helper