|
@@ -5,14 +5,16 @@ import re
|
5
|
5
|
import datetime as datetimeroot
|
6
|
6
|
from datetime import datetime
|
7
|
7
|
from hashlib import sha256
|
8
|
|
-__all__ = ['User', 'Group', 'Permission']
|
9
|
8
|
|
10
|
9
|
from sqlalchemy import Table, ForeignKey, Column, Sequence
|
11
|
10
|
from sqlalchemy.types import Unicode, Integer, DateTime, Text, LargeBinary
|
12
|
11
|
from sqlalchemy.orm import relation, synonym, relationship
|
13
|
12
|
from sqlalchemy.orm import backref
|
|
13
|
+import sqlalchemy.orm as sqlao
|
14
|
14
|
from sqlalchemy import orm as sqlao
|
15
|
15
|
|
|
16
|
+from tg.i18n import ugettext as _, lazy_ugettext as l_
|
|
17
|
+
|
16
|
18
|
import tg
|
17
|
19
|
from pboard.model import DeclarativeBase, metadata, DBSession
|
18
|
20
|
|
|
@@ -92,29 +94,52 @@ class PBNodeStatusItem(object):
|
92
|
94
|
class PBNodeStatus(object):
|
93
|
95
|
|
94
|
96
|
StatusList = dict()
|
95
|
|
- StatusList['immortal'] = PBNodeStatusItem('immortal', 'Information', 'normal', 'fa fa-info-circle', 'pod-status-grey-light')
|
96
|
|
- StatusList['new'] = PBNodeStatusItem('new', 'New', 'open', 'fa fa-lightbulb-o', 'btn-success')
|
97
|
|
- StatusList['inprogress'] = PBNodeStatusItem('inprogress', 'In progress', 'open', 'fa fa-gears fa-inverse', 'btn-info')
|
98
|
|
- StatusList['actiontodo'] = PBNodeStatusItem('actiontodo', 'Action to do', 'open', 'fa fa-spinner fa-inverse', 'btn-info')
|
99
|
|
- StatusList['standby'] = PBNodeStatusItem('standby', 'Waiting for news', 'open', 'fa fa-spinner fa-inverse', 'btn-warning')
|
100
|
|
- StatusList['hot'] = PBNodeStatusItem('hot', 'Hot', 'open', 'fa fa-warning fa-inverse', 'btn-danger')
|
101
|
|
- StatusList['done'] = PBNodeStatusItem('done', 'Done', 'closed', 'fa fa-check-square-o', 'pod-status-grey-light')
|
102
|
|
- StatusList['closed'] = PBNodeStatusItem('closed', 'Closed', 'closed', 'fa fa-lightbulb-o', 'pod-status-grey-middle')
|
103
|
|
- StatusList['archived'] = PBNodeStatusItem('archived', 'Archived', 'invisible', 'fa fa-archive', 'pod-status-grey-dark')
|
104
|
|
- StatusList['deleted'] = PBNodeStatusItem('deleted', 'Deleted', 'invisible', 'fa fa-trash-o', 'pod-status-grey-dark')
|
|
97
|
+ StatusList['information'] = PBNodeStatusItem('information', 'Information', 'normal', 'fa fa-info-circle', 'pod-status-grey-light')
|
|
98
|
+ StatusList['automatic'] = PBNodeStatusItem('automatic', 'Automatic', 'open', 'fa fa-flash', 'pod-status-grey-light')
|
|
99
|
+ StatusList['new'] = PBNodeStatusItem('new', 'New', 'open', 'fa fa-lightbulb-o fa-inverse', 'btn-success')
|
|
100
|
+ StatusList['inprogress'] = PBNodeStatusItem('inprogress', 'In progress', 'open', 'fa fa-gears fa-inverse', 'btn-info')
|
|
101
|
+ StatusList['standby'] = PBNodeStatusItem('standby', 'In standby', 'open', 'fa fa-spinner fa-inverse', 'btn-warning')
|
|
102
|
+ StatusList['done'] = PBNodeStatusItem('done', 'Done', 'closed', 'fa fa-check-square-o', 'pod-status-grey-light')
|
|
103
|
+ StatusList['closed'] = PBNodeStatusItem('closed', 'Closed', 'closed', 'fa fa-lightbulb-o', 'pod-status-grey-middle')
|
|
104
|
+ StatusList['deleted'] = PBNodeStatusItem('deleted', 'Deleted', 'closed', 'fa fa-trash-o', 'pod-status-grey-dark')
|
|
105
|
+
|
|
106
|
+ @classmethod
|
|
107
|
+ def getChoosableList(cls):
|
|
108
|
+ return [
|
|
109
|
+ PBNodeStatus.StatusList['information'],
|
|
110
|
+ PBNodeStatus.StatusList['automatic'],
|
|
111
|
+ PBNodeStatus.StatusList['new'],
|
|
112
|
+ PBNodeStatus.StatusList['inprogress'],
|
|
113
|
+ PBNodeStatus.StatusList['standby'],
|
|
114
|
+ PBNodeStatus.StatusList['done'],
|
|
115
|
+ PBNodeStatus.StatusList['closed'],
|
|
116
|
+ ]
|
|
117
|
+
|
|
118
|
+ @classmethod
|
|
119
|
+ def getVisibleIdsList(cls):
|
|
120
|
+ return ['information', 'automatic', 'new', 'inprogress', 'standby', 'done' ]
|
|
121
|
+
|
|
122
|
+ @classmethod
|
|
123
|
+ def getVisibleList(cls):
|
|
124
|
+ return [
|
|
125
|
+ PBNodeStatus.StatusList['information'],
|
|
126
|
+ PBNodeStatus.StatusList['automatic'],
|
|
127
|
+ PBNodeStatus.StatusList['new'],
|
|
128
|
+ PBNodeStatus.StatusList['inprogress'],
|
|
129
|
+ PBNodeStatus.StatusList['standby'],
|
|
130
|
+ PBNodeStatus.StatusList['done'],
|
|
131
|
+ ]
|
105
|
132
|
|
106
|
133
|
@classmethod
|
107
|
134
|
def getList(cls):
|
108
|
135
|
return [
|
109
|
|
- PBNodeStatus.StatusList['immortal'],
|
|
136
|
+ PBNodeStatus.StatusList['information'],
|
|
137
|
+ PBNodeStatus.StatusList['automatic'],
|
110
|
138
|
PBNodeStatus.StatusList['new'],
|
111
|
|
- PBNodeStatus.StatusList['actiontodo'],
|
112
|
139
|
PBNodeStatus.StatusList['inprogress'],
|
113
|
140
|
PBNodeStatus.StatusList['standby'],
|
114
|
|
- PBNodeStatus.StatusList['hot'],
|
115
|
141
|
PBNodeStatus.StatusList['done'],
|
116
|
142
|
PBNodeStatus.StatusList['closed'],
|
117
|
|
- PBNodeStatus.StatusList['archived'],
|
118
|
143
|
PBNodeStatus.StatusList['deleted']
|
119
|
144
|
]
|
120
|
145
|
|
|
@@ -162,8 +187,8 @@ class PBNode(DeclarativeBase):
|
162
|
187
|
parent_tree_path = Column(Unicode(255), unique=False, nullable=False, default='')
|
163
|
188
|
owner_id = Column(Integer, ForeignKey('pod_user.user_id'), nullable=True, default=None)
|
164
|
189
|
|
165
|
|
- node_order = Column(Integer, nullable=True, default=1)
|
166
|
|
- node_type = Column(Unicode(16), unique=False, nullable=False, default='data')
|
|
190
|
+ node_order = Column(Integer, nullable=True, default=1)
|
|
191
|
+ node_type = Column(Unicode(16), unique=False, nullable=False, default='data')
|
167
|
192
|
node_status = Column(Unicode(16), unique=False, nullable=False, default='new')
|
168
|
193
|
|
169
|
194
|
created_at = Column(DateTime, unique=False, nullable=False)
|
|
@@ -177,7 +202,7 @@ class PBNode(DeclarativeBase):
|
177
|
202
|
|
178
|
203
|
data_file_name = Column(Unicode(255), unique=False, nullable=False, default='')
|
179
|
204
|
data_file_mime_type = Column(Unicode(255), unique=False, nullable=False, default='')
|
180
|
|
- data_file_content = Column(LargeBinary(), unique=False, nullable=False, default=None)
|
|
205
|
+ data_file_content = sqlao.deferred(Column(LargeBinary(), unique=False, nullable=False, default=None))
|
181
|
206
|
|
182
|
207
|
|
183
|
208
|
_oParent = relationship('PBNode', remote_side=[node_id], backref='_lAllChildren')
|
|
@@ -280,7 +305,19 @@ class PBNode(DeclarativeBase):
|
280
|
305
|
return poDateTime.strftime(psDateTimeFormat)
|
281
|
306
|
|
282
|
307
|
def getStatus(self):
|
283
|
|
- return PBNodeStatus.getStatusItem(self.node_status)
|
|
308
|
+ loStatus = PBNodeStatus.getStatusItem(self.node_status)
|
|
309
|
+ if loStatus.status_id!='automatic':
|
|
310
|
+ return loStatus
|
|
311
|
+ else:
|
|
312
|
+ # Compute the status:
|
|
313
|
+ # - if at least one child is 'new' or 'in progress' or 'in standby' => status is inprogress
|
|
314
|
+ # - else if all status are 'done', 'closed' or 'deleted' => 'done'
|
|
315
|
+ lsRealStatusId = 'done'
|
|
316
|
+ for loChild in self.getChildren():
|
|
317
|
+ if loChild.getStatus().status_id in ('new', 'inprogress', 'standby'):
|
|
318
|
+ lsRealStatusId = 'inprogress'
|
|
319
|
+ break
|
|
320
|
+ return PBNodeStatus.getStatusItem(lsRealStatusId)
|
284
|
321
|
|
285
|
322
|
def getTruncatedLabel(self, piCharNb):
|
286
|
323
|
lsTruncatedLabel = ''
|