38 |
38 |
39 |
39 |
40 class CWRType(AnyEntity): |
40 class CWRType(AnyEntity): |
41 id = 'CWRType' |
41 id = 'CWRType' |
42 fetch_attrs, fetch_order = fetch_config(['name']) |
42 fetch_attrs, fetch_order = fetch_config(['name']) |
43 |
43 |
44 def dc_title(self): |
44 def dc_title(self): |
45 return self.req._(self.name) |
45 return self.req._(self.name) |
46 |
46 |
47 def dc_long_title(self): |
47 def dc_long_title(self): |
48 stereotypes = [] |
48 stereotypes = [] |
49 _ = self.req._ |
49 _ = self.req._ |
50 if self.meta: |
50 if self.meta: |
51 stereotypes.append(_('meta')) |
51 stereotypes.append(_('meta')) |
59 return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes)) |
59 return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes)) |
60 return self.dc_title() |
60 return self.dc_title() |
61 |
61 |
62 def inlined_changed(self, inlined): |
62 def inlined_changed(self, inlined): |
63 """check inlining is necessary and possible: |
63 """check inlining is necessary and possible: |
64 |
64 |
65 * return False if nothing has changed |
65 * return False if nothing has changed |
66 * raise ValidationError if inlining is'nt possible |
66 * raise ValidationError if inlining is'nt possible |
67 * eventually return True |
67 * eventually return True |
68 """ |
68 """ |
69 rtype = self.name |
69 rtype = self.name |
86 |
86 |
87 |
87 |
88 class CWRelation(AnyEntity): |
88 class CWRelation(AnyEntity): |
89 id = 'CWRelation' |
89 id = 'CWRelation' |
90 fetch_attrs = fetch_config(['cardinality'])[0] |
90 fetch_attrs = fetch_config(['cardinality'])[0] |
91 |
91 |
92 def dc_title(self): |
92 def dc_title(self): |
93 return u'%s %s %s' % ( |
93 return u'%s %s %s' % ( |
94 self.from_entity[0].name, |
94 self.from_entity[0].name, |
95 self.relation_type[0].name, |
95 self.relation_type[0].name, |
96 self.to_entity[0].name) |
96 self.to_entity[0].name) |
97 |
97 |
98 def dc_long_title(self): |
98 def dc_long_title(self): |
99 card = self.cardinality |
99 card = self.cardinality |
100 scard, ocard = u'', u'' |
100 scard, ocard = u'', u'' |
101 if card[0] != '1': |
101 if card[0] != '1': |
102 scard = '[%s]' % card[0] |
102 scard = '[%s]' % card[0] |
116 return super(CWRelation, self).after_deletion_path() |
116 return super(CWRelation, self).after_deletion_path() |
117 |
117 |
118 |
118 |
119 class CWAttribute(CWRelation): |
119 class CWAttribute(CWRelation): |
120 id = 'CWAttribute' |
120 id = 'CWAttribute' |
121 |
121 |
122 def dc_long_title(self): |
122 def dc_long_title(self): |
123 card = self.cardinality |
123 card = self.cardinality |
124 scard = u'' |
124 scard = u'' |
125 if card[0] == '1': |
125 if card[0] == '1': |
126 scard = '+' |
126 scard = '+' |
127 return u'%s %s%s %s' % ( |
127 return u'%s %s%s %s' % ( |
128 self.from_entity[0].name, |
128 self.from_entity[0].name, |
129 scard, self.relation_type[0].name, |
129 scard, self.relation_type[0].name, |
130 self.to_entity[0].name) |
130 self.to_entity[0].name) |
131 |
131 |
132 |
132 |
133 class CWConstraint(AnyEntity): |
133 class CWConstraint(AnyEntity): |
134 id = 'CWConstraint' |
134 id = 'CWConstraint' |
135 fetch_attrs, fetch_order = fetch_config(['value']) |
135 fetch_attrs, fetch_order = fetch_config(['value']) |
136 |
136 |
137 def dc_title(self): |
137 def dc_title(self): |
138 return '%s(%s)' % (self.cstrtype[0].name, self.value or u'') |
138 return '%s(%s)' % (self.cstrtype[0].name, self.value or u'') |
139 |
139 |
140 def after_deletion_path(self): |
140 def after_deletion_path(self): |
141 """return (path, parameters) which should be used as redirect |
141 """return (path, parameters) which should be used as redirect |
142 information when this entity is being deleted |
142 information when this entity is being deleted |
143 """ |
143 """ |
144 if self.reverse_constrained_by: |
144 if self.reverse_constrained_by: |
162 for rel in ('read_permission', 'add_permission', 'delete_permission', |
162 for rel in ('read_permission', 'add_permission', 'delete_permission', |
163 'update_permission', 'condition'): |
163 'update_permission', 'condition'): |
164 values = getattr(self, 'reverse_%s' % rel) |
164 values = getattr(self, 'reverse_%s' % rel) |
165 if values: |
165 if values: |
166 return values[0] |
166 return values[0] |
167 |
167 |
168 @cached |
168 @cached |
169 def _rqlexpr(self): |
169 def _rqlexpr(self): |
170 if self.exprtype == 'ERQLExpression': |
170 if self.exprtype == 'ERQLExpression': |
171 return ERQLExpression(self.expression, self.mainvars, self.eid) |
171 return ERQLExpression(self.expression, self.mainvars, self.eid) |
172 #if self.exprtype == 'RRQLExpression': |
172 #if self.exprtype == 'RRQLExpression': |
173 return RRQLExpression(self.expression, self.mainvars, self.eid) |
173 return RRQLExpression(self.expression, self.mainvars, self.eid) |
174 |
174 |
175 def check_expression(self, *args, **kwargs): |
175 def check_expression(self, *args, **kwargs): |
176 return self._rqlexpr().check(*args, **kwargs) |
176 return self._rqlexpr().check(*args, **kwargs) |
177 |
177 |
178 def after_deletion_path(self): |
178 def after_deletion_path(self): |
179 """return (path, parameters) which should be used as redirect |
179 """return (path, parameters) which should be used as redirect |
180 information when this entity is being deleted |
180 information when this entity is being deleted |
181 """ |
181 """ |
182 if self.expression_of: |
182 if self.expression_of: |
190 |
190 |
191 def dc_title(self): |
191 def dc_title(self): |
192 if self.label: |
192 if self.label: |
193 return '%s (%s)' % (self.req._(self.name), self.label) |
193 return '%s (%s)' % (self.req._(self.name), self.label) |
194 return self.req._(self.name) |
194 return self.req._(self.name) |
195 |
195 |
196 def after_deletion_path(self): |
196 def after_deletion_path(self): |
197 """return (path, parameters) which should be used as redirect |
197 """return (path, parameters) which should be used as redirect |
198 information when this entity is being deleted |
198 information when this entity is being deleted |
199 """ |
199 """ |
200 permissionof = getattr(self, 'reverse_require_permission', ()) |
200 permissionof = getattr(self, 'reverse_require_permission', ()) |