Beispiel #1
0
 def _init_components(self):
     super(SecurityEditWindow, self)._init_components()
     self.code_field = ext.ExtStringField(
         label=_(u"Код"),
         name="code",
         allow_blank=False,
         anchor="100%")
     self.module_field = make_combo_box(
         label=_(u"Модуль"),
         name="module",
         allow_blank=False,
         anchor="100%")
     self.name_field = ext.ExtStringField(
         label=_(u"Наименование"),
         name="name",
         allow_blank=False,
         anchor="100%")
     self.hash_field = ext.ExtStringField(
         name="hash",
         hidden=True)
     self.param_grid = ext.ExtObjectGrid(
         header=True,
         title=u"Параметры",
         anchor="100%",
         height=150,
     )
Beispiel #2
0
    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))
Beispiel #3
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%')
Beispiel #4
0
    def _init_components(self):
        """
		Здесь следует инициализировать компоненты окна и складывать их в
		:attr:`self`.
		"""
        super(UserAddEditWindow, self)._init_components()

        self.field__name = ext.ExtStringField(label=u'username',
                                              name='username',
                                              allow_blank=False,
                                              anchor='100%')
        self.field__password = ext.ExtStringField(label=u'password',
                                                  name='password',
                                                  allow_blank=False,
                                                  anchor='100%')
        self.field__first_name = ext.ExtStringField(label=u'first_name',
                                                    name='first_name',
                                                    allow_blank=True,
                                                    anchor='100%')
        self.field__last_name = ext.ExtStringField(label=u'last_name',
                                                   name='last_name',
                                                   allow_blank=True,
                                                   anchor='100%')
        self.field__email = ext.ExtStringField(label=u'email',
                                               name='email',
                                               allow_blank=True,
                                               anchor='100%')
        self.field__is_superuser = ExtCheckBox(
            label=u'is_superuser',
            name='is_superuser',
            anchor='100%',
        )
        self.field__is_staff = ExtCheckBox(
            label=u'is_staff',
            name='is_staff',
            anchor='100%',
        )
        self.field__last_login = ExtDateField(
            name='last_login',
            label=u'last_login',
            format='d.m.yy',
        )
        self.field__date_joined = ExtDateField(
            name='date_joined',
            label=u'date_joined',
            format='d.m.yy',
        )
Beispiel #5
0
    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%')
Beispiel #6
0
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """
        super(PermissionAddWindow, self)._init_components()

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

        self.field__content_type = ext.ExtDictSelectField(
            label=u'content type',
            name='content_type',
            pack=app.actions.ContentTypePack)

        self.field__codename = ext.ExtStringField(label=u'codename',
                                                  name='codename',
                                                  allow_blank=False,
                                                  anchor='100%')
Beispiel #7
0
 def _init_components(self):
     super(ServiceEditWindow, self)._init_components()
     self.code_field = ext.ExtStringField(
         label=_(u"Код"),
         name="code",
         allow_blank=False,
         anchor="100%")
     self.name_field = ext.ExtStringField(
         label=_(u"Наименование"),
         name="name",
         allow_blank=False,
         anchor="100%")
     self.api_json_field = ext.ExtStringField(
         name="api_flat_json",
         hidden=True)
     self.hash_field = ext.ExtStringField(
         name="hash",
         hidden=True)
     self.api_grid = ext.ExtObjectGrid(
         header=True,
         title=_(u"Сервис-методы"),
         flex=1)
Beispiel #8
0
    def init_components(self, win):
        super(ApplicationMainTab, self).init_components(win)
        win.service_field = make_combo_box(
            name="service",
            label=_(u"Услуга"),
            allow_blank=False,
            anchor="100%")
        win.name_field = ext.ExtStringField(
            name="name",
            label=_(u"Код"),
            allow_blank=False,
            anchor="100%")

        win.tns_field = ext.ExtStringField(
            name="tns",
            label=_(u"TNS"),
            anchor="100%",
            allow_blank=True)

        win.hash_field = ext.ExtStringField(
            name="hash",
            hidden=True)
Beispiel #9
0
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """
        super(OrganizationAddWindow, self)._init_components()

        self.field__name = ext.ExtStringField(
            label=u'Название',
            name='name',
            allow_blank=False,
            anchor='100%')

        self.field__inn = ext.ExtStringField(
            label=u'ИНН',
            name='inn',
            allow_blank=False,
            anchor='100%')

        self.field__kpp = ext.ExtStringField(
            label=u'КПП',
            name='kpp',
            allow_blank=False,
            anchor='100%')
Beispiel #10
0
    def _init_components(self):
        """
        Здесь следует инициализировать компоненты окна и складывать их в
        :attr:`self`.
        """
        super(PersonAddWindow, self)._init_components()

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

        self.field__surname = ext.ExtStringField(
            label=u'Фамилия',
            name='surname',
            allow_blank=False,
            anchor='100%')

        self.field__patronymic = ext.ExtStringField(
            label=u'Отчество',
            name='patronymic',
            allow_blank=False,
            anchor='100%')

        self.field__birth_date = ext.ExtDateField(
            label=u'Дата рождения',
            name='birth_date',
            anchor='100%')

        self.field__organization_id = make_combo_box(
            label=u'Учреждение',
            name='organization_id',
            allow_blank=False,
            anchor='100%',
            data=Organization.objects.all().values_list('pk', 'name'))
Beispiel #11
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%')
Beispiel #12
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