コード例 #1
0
ファイル: ui.py プロジェクト: SH0UMEN/bars-test
    def _init_components(self):
        super(UserAddAndEditWindow, self)._init_components()

        self.field__username = ext.ExtStringField(label=u'Имя пользователя',
                                                  name='username',
                                                  allow_blank=False,
                                                  anchor='100%')

        self.field__lastname = ext.ExtStringField(label=u'Фамилия',
                                                  name='last_name',
                                                  allow_blank=True,
                                                  anchor='100%')

        self.field__name = ext.ExtStringField(label=u'Имя',
                                              name='first_name',
                                              allow_blank=True,
                                              anchor='100%')

        self.field__email = ext.ExtStringField(label=u'Email',
                                               name='email',
                                               allow_blank=True,
                                               anchor='100%')

        self.field__password = ext.ExtStringField(label=u'Пароль',
                                                  name='password',
                                                  allow_blank=False,
                                                  anchor='100%')

        self.field__last_login = ext.ExtDateField(
            label=u'Дата последнего входа',
            name='last_login',
            format='d.m.Y',
            anchor='100%')

        self.field__date_joined = ext.ExtDateField(label=u'Дата регистрации',
                                                   name='date_joined',
                                                   format='d.m.Y',
                                                   anchor='100%')

        self.field__is_staff = ext.ExtCheckBox(label=u'Администратор',
                                               name='is_staff',
                                               anchor='100%')

        self.field__is_staff = ext.ExtCheckBox(label=u'Администратор',
                                               name='is_staff',
                                               anchor='100%')

        self.field__is_superuser = ext.ExtCheckBox(label=u'Все права',
                                                   name='is_superuser',
                                                   anchor='100%')

        self.field__is_active = ext.ExtCheckBox(label=u'Активен',
                                                name='is_active',
                                                anchor='100%')

        self.form.items.extend(
            (self.field__username, self.field__email, self.field__lastname,
             self.field__name, self.field__password, self.field__last_login,
             self.field__date_joined, self.field__is_staff,
             self.field__is_superuser, self.field__is_active))
コード例 #2
0
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """
        super(UserAddWindow, self)._init_components()

        self.field__password = ext.ExtStringField(label=u'password',
                                                  name='password',
                                                  allow_blank=False,
                                                  anchor='100%')

        self.field__last_login = ext.ExtDateField(label=u'last login',
                                                  name='last_login',
                                                  anchor='100%')

        self.field__is_superuser = ext.ExtCheckBox(label=u'superuser',
                                                   name='superuser',
                                                   checked=False,
                                                   anchor='100%')

        self.field__username = ext.ExtStringField(label=u'username',
                                                  name='username',
                                                  allow_blank=False,
                                                  anchor='100%')

        self.field__first_name = ext.ExtStringField(label=u'first name',
                                                    name='first_name',
                                                    anchor='100%')

        self.field__last_name = ext.ExtStringField(label=u'last name',
                                                   name='last_name',
                                                   anchor='100%')

        self.field__email = ext.ExtStringField(label=u'email address',
                                               name='email',
                                               anchor='100%')

        self.field__is_staff = ext.ExtCheckBox(label=u'is staff',
                                               name='is_staff',
                                               checked=False,
                                               anchor='100%')

        self.field__is_active = ext.ExtCheckBox(label=u'is active',
                                                name='is_active',
                                                checked=True,
                                                anchor='100%')

        self.field__joined = ext.ExtDateField(label=u'date joined',
                                              name='joined',
                                              value=datetime.date.today,
                                              anchor='100%')
コード例 #3
0
ファイル: ui.py プロジェクト: AVoronina/test_task
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """

        super(UserWindow, self)._init_components()

        self.field_username = ext.ExtStringField(label=u'Username',
                                                 name='username',
                                                 allow_blank=False,
                                                 anchor='100%')

        self.field_first_name = ext.ExtStringField(label=u'First name',
                                                   name='first_name',
                                                   allow_blank=False,
                                                   anchor='100%')

        self.field_last_name = ext.ExtStringField(label=u'Last name',
                                                  name='last_name',
                                                  allow_blank=False,
                                                  anchor='100%')

        self.field_last_login = ext.ExtDateField(label=u'Last login',
                                                 name='last_login',
                                                 anchor='100%')

        self.field_is_active = ext.ExtCheckBox(label=u'Is active',
                                               name='is_active',
                                               allow_blank=False,
                                               anchor='100%')

        self.field_is_staff = ext.ExtCheckBox(label=u'Is staff',
                                              name='is_staff',
                                              allow_blank=True,
                                              anchor='100%')

        self.field_date_joined = ext.ExtDateField(label=u'Date joined',
                                                  name='date_joined',
                                                  allow_blank=True,
                                                  anchor='100%')
コード例 #4
0
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """
        super(UserAddEditWindow, self)._init_components()

        self.field__password = ext.ExtStringField(
            label='password',
            name='password',
            allow_blank=False,
            anchor='100%')

        self.field__last_login = ext.ExtDateField(
            label='last login',
            name='last login',
            anchor='100%',
            format='d.m.Y')

        self.field__su_status = ext.ExtCheckBox(
            label='active',
            name='active',
            anchor='100%')

        self.field__username = ext.ExtStringField(
            label='username',
            name='username',
            allow_blank=False,
            anchor='100%')

        self.field__name = ext.ExtStringField(
            label='first name',
            name='name',
            anchor='100%')

        self.field__surname = ext.ExtStringField(
            label='last name',
            name='surname',
            anchor='100%')

        self.field__email = ext.ExtStringField(
            label='email address',
            name='email',
            anchor='100%')

        self.field__date = ext.ExtDateField(
            label='date joined',
            name='date',
            anchor='100%',
            format='d.m.Y')

        self.field__staff_status = ext.ExtCheckBox(
            label='active',
            name='active',
            anchor='100%')

        self.field__active = ext.ExtCheckBox(
            label='active',
            name='active',
            checked=True,
            anchor='100%')

        self.field__date = ext.ExtDateField(
            label='date joined',
            name='date',
            format='d.m.Y',
            value=datetime.date.today(),
            anchor='100%')
コード例 #5
0
def _create_control_for_field(f, model_register=None, **kwargs):
    """
    создает контрол для поля f = models.Field from model
    """
    name = str(f.attname)

    if f.choices:
        ctl = make_combo_box(data=list(f.choices), **kwargs)

    elif isinstance(f, django_models.BooleanField):
        ctl = ext.ExtCheckBox(**kwargs)

    elif isinstance(f, django_models.CharField):
        ctl = ext.ExtStringField(max_length=f.max_length, **kwargs)

    elif isinstance(f, django_models.TextField):
        ctl = ext.ExtTextArea(max_length=f.max_length, **kwargs)

    elif isinstance(f, django_models.IntegerField):
        ctl = ext.ExtNumberField(**kwargs)
        ctl.allow_decimals = False
        if isinstance(f, (django_models.PositiveIntegerField,
                          django_models.PositiveSmallIntegerField)):
            ctl.allow_negative = False

    elif isinstance(f, django_models.FloatField):
        ctl = ext.ExtNumberField(**kwargs)
        ctl.allow_decimals = True

    elif isinstance(f, django_models.DecimalField):
        ctl = ext.ExtNumberField(**kwargs)
        ctl.allow_decimals = True
        ctl.decimal_precision = f.decimal_places

    elif isinstance(f, (django_models.DateTimeField, django_models.DateField)):
        params = {'format': 'd.m.Y'}
        params.update(kwargs)
        ctl = ext.ExtDateField(**params)

    elif isinstance(f, django_models.TimeField):
        params = {'format': 'H:i', 'increment': 5}
        params.update(kwargs)
        ctl = ext.ExtTimeField(**params)

    elif isinstance(f, django_models.ForeignKey):
        ctl = _create_dict_select_field(f, model_register, **kwargs)

    elif isinstance(f, django_models.ImageField):
        ctl = ext.ExtImageUploadField(**kwargs)

    elif isinstance(f, django_models.FileField):
        ctl = ext.ExtFileUploadField(**kwargs)

    else:
        raise GenerationError(u'Не могу создать контрол для %s' % f)

    ctl.name = name
    ctl.label = unicode(f.verbose_name or name)
    ctl.allow_blank = f.blank

    if ctl.allow_blank and hasattr(ctl, 'hide_clear_trigger'):
        ctl.hide_clear_trigger = False

    # простановка значения по-умолчанию, если таковое указано для поля
    default = getattr(f, 'default', None)
    if default and default is not django_models.NOT_PROVIDED:
        if callable(default):
            default = default()
        ctl.value = default
        # если поле - combobox, то поставляется не только значение, но и текст
        if hasattr(ctl, 'display_field'):
            for k, v in (f.choices or []):
                if default == k:
                    ctl.default_text = v
                    break

    return ctl