Beispiel #1
0
class FilmModel(ModelView):
    form_extra_fields = {
        'file':
        FileUploadField('Загрузка файла',
                        base_path=app.config['UPLOAD_FOLDER'],
                        namegen=prefix_name)
    }
    form_excluded_columns = ('episodes')
    column_labels = dict(name='Название', url='Ссылка')

    create_template = 'admin_edit.html'
    edit_template = 'admin_edit.html'

    def is_accessible(self):
        if not basic_auth.authenticate():
            raise AuthException('Not authenticated. Refresh the page.')
        else:
            return True

    def inaccessible_callback(self, name, **kwargs):
        return redirect(basic_auth.challenge())

    def on_model_change(self, form, Film, is_created=False):
        if not form.video.data:
            try:
                Film.video = os.path.join(app.config['UPLOAD_FOLDER'],
                                          form.file.data.filename)
            except:
                pass
Beispiel #2
0
class SettingsModel(ModelView):
    form_extra_fields = {
        'file':
        FileUploadField('file',
                        base_path=app.config['UPLOAD_FOLDER'],
                        namegen=prefix_name)
    }

    form_widget_args = {
        'name': {
            'readonly': True
        },
    }

    def is_accessible(self):
        if not basic_auth.authenticate():
            raise AuthException('Not authenticated. Refresh the page.')
        else:
            return True

    def inaccessible_callback(self, name, **kwargs):
        return redirect(basic_auth.challenge())

    def on_model_change(self, form, Setting, is_created=False):
        if not form.value.data:
            Setting.value = os.path.join(app.config['UPLOAD_FOLDER'],
                                         form.file.data.filename)
Beispiel #3
0
class StorageAdminModel(ModelView):
    form_extra_fields = {
        'file':
        FileUploadField('file',
                        base_path=app.config['UPLOAD_FOLDER'],
                        namegen=prefix_name)
    }

    def on_model_change(self, form, Setting, is_created=False):
        if not form.value.data:
            Setting.value = os.path.join(app.config['UPLOAD_FOLDER'],
                                         form.file.data.filename)
Beispiel #4
0
class PersonView(sqla.ModelView):
    """Create customized model view class."""
    edit_template = 'admin/person_edit.html'
    # Change edit in the admin
    can_view_details = False
    column_searchable_list = ['login', 'name', 'surname']
    form_columns = ('login', 'photo', 'name', 'surname', 'job', 'skype',
                    'email', 'fixe', 'mobile', 'subordinates', 'team',
                    'manager', 'birthday', 'arrival')
    column_labels = dict(login='******',
                         photo='Photo de la personne',
                         name='Nom',
                         surname='Prénom',
                         job='Métier',
                         skype='Suite Métier',
                         email='Mail',
                         fixe='Téléphone',
                         mobile='Numéro du poste',
                         subordinates='Vérification',
                         team='Service',
                         manager='Chef de service',
                         birthday='Date de saisie',
                         arrival='Date de sauvegarde')

    def is_accessible(self):
        """Check if the current user can access the view."""
        return login.current_user.is_authenticated

    def image_name(obj, file_data):
        return obj.login + ".jpg"

    form_extra_fields = {
        'photo':
        FileUploadField('Photo',
                        base_path=config.PHOTOS_FOLDER,
                        namegen=image_name)
    }
Beispiel #5
0
class ClientForm(Form):
    tbl = FileUploadField('File', namegen=prefix_name, validators=[DataRequired()])
Beispiel #6
0
class Comment(form.Form):
    title = fields.StringField("title")
    name = fields.StringField("name")
    profession = fields.StringField("prof")
    img = FileUploadField(label="image", base_path=path)
    text = CKTextAreaField("text")
Beispiel #7
0
class Article(form.Form):
    title = fields.StringField("title")
    img = FileUploadField(label="image", base_path=path)
    text = CKTextAreaField("text")
    tags = fields.StringField("tags")