1
- from basemodels import BaseMixin
1
+ import sqlalchemy as sa
2
+ from ...basemodels import BaseMixin
2
3
from LoginUtils import check_password , encrypt_password
3
- from ext import db
4
+ print 'importing flask_xxl.apps.admin.models as ' , __name__
4
5
5
- for attr in dir (db ):
6
- globals ()[attr ] = getattr (db ,attr )
7
6
7
+ class Setting (BaseMixin ):
8
8
9
- class Setting (BaseMixin ,Model ):
10
- __tablename__ = 'settings'
11
-
12
- name = Column (String (255 ),nullable = False ,unique = True )
13
- setting_type_id = Column (Integer ,ForeignKey ('types.id' ))
14
- setting_type = relationship ('Type' ,backref = backref (
9
+ name = sa .Column (sa .String (255 ),nullable = False ,unique = True )
10
+ setting_type_id = sa .Column (sa .Integer ,sa .ForeignKey ('types.id' ))
11
+ setting_type = sa .orm .relationship ('Type' ,backref = sa .orm .backref (
15
12
'settings' ,lazy = 'dynamic' ))
16
- default = Column (String (255 ))
17
- value = Column (String (255 ))
13
+ default = sa . Column (sa . String (255 ))
14
+ value = sa . Column (sa . String (255 ))
18
15
19
16
@property
20
17
def widget (self ):
@@ -23,27 +20,26 @@ def widget(self):
23
20
else :
24
21
return ''
25
22
26
- class Type (BaseMixin , Model ):
27
- __tablename__ = 'types'
23
+ class Type (BaseMixin ):
24
+
28
25
29
- name = Column (String (255 ),nullable = False )
30
- widgets = relationship ('Widget' ,backref = backref (
26
+ name = sa . Column (sa . String (255 ),nullable = False )
27
+ widgets = sa . orm . relationship ('Widget' ,backref = sa . orm . backref (
31
28
'type' ),lazy = 'dynamic' )
32
- html = Column (Text )
33
- field_type = Column (String (255 ))
34
- required = Column (Boolean ,default = False )
35
- data_type = Column (String (255 ))
29
+ html = sa . orm . Column (sa . orm . Text )
30
+ field_type = sa . Column (sa . String (255 ))
31
+ required = sa . Column (sa . Boolean ,default = False )
32
+ data_type = sa . Column (sa . String (255 ))
36
33
37
34
def __repr__ (self ):
38
35
return self .name or ''
39
36
40
- class Widget (BaseMixin ,db .Model ):
41
- __tablename__ = 'widgets'
37
+ class Widget (BaseMixin ):
42
38
43
- name = Column (String (255 ),nullable = False )
44
- title = Column (String (255 ))
45
- content = Column (Text ,nullable = False )
46
- type_id = Column (Integer ,ForeignKey ('types.id' ))
39
+ name = sa . Column (sa . String (255 ),nullable = False )
40
+ title = sa . Column (sa . String (255 ))
41
+ content = sa . Column (sa . Text ,nullable = False )
42
+ type_id = sa . Column (sa . Integer ,sa . ForeignKey ('types.id' ))
47
43
48
44
def __repr__ (self ):
49
45
return self .name
0 commit comments