113 return u'%s %s%s%s %s' % ( |
113 return u'%s %s%s%s %s' % ( |
114 self.from_entity[0].name, |
114 self.from_entity[0].name, |
115 scard, self.relation_type[0].name, ocard, |
115 scard, self.relation_type[0].name, ocard, |
116 self.to_entity[0].name) |
116 self.to_entity[0].name) |
117 |
117 |
118 def after_deletion_path(self): |
|
119 """return (path, parameters) which should be used as redirect |
|
120 information when this entity is being deleted |
|
121 """ |
|
122 if self.relation_type: |
|
123 return self.relation_type[0].rest_path(), {} |
|
124 return super(CWRelation, self).after_deletion_path() |
|
125 |
|
126 @property |
118 @property |
127 def rtype(self): |
119 def rtype(self): |
128 return self.relation_type[0] |
120 return self.relation_type[0] |
129 |
121 |
130 @property |
122 @property |
136 return self.to_entity[0] |
128 return self.to_entity[0] |
137 |
129 |
138 def yams_schema(self): |
130 def yams_schema(self): |
139 rschema = self._cw.vreg.schema.rschema(self.rtype.name) |
131 rschema = self._cw.vreg.schema.rschema(self.rtype.name) |
140 return rschema.rdefs[(self.stype.name, self.otype.name)] |
132 return rschema.rdefs[(self.stype.name, self.otype.name)] |
|
133 |
141 |
134 |
142 class CWAttribute(CWRelation): |
135 class CWAttribute(CWRelation): |
143 __regid__ = 'CWAttribute' |
136 __regid__ = 'CWAttribute' |
144 |
137 |
145 def dc_long_title(self): |
138 def dc_long_title(self): |
157 __regid__ = 'CWConstraint' |
150 __regid__ = 'CWConstraint' |
158 fetch_attrs, fetch_order = fetch_config(['value']) |
151 fetch_attrs, fetch_order = fetch_config(['value']) |
159 |
152 |
160 def dc_title(self): |
153 def dc_title(self): |
161 return '%s(%s)' % (self.cstrtype[0].name, self.value or u'') |
154 return '%s(%s)' % (self.cstrtype[0].name, self.value or u'') |
162 |
|
163 def after_deletion_path(self): |
|
164 """return (path, parameters) which should be used as redirect |
|
165 information when this entity is being deleted |
|
166 """ |
|
167 if self.reverse_constrained_by: |
|
168 return self.reverse_constrained_by[0].rest_path(), {} |
|
169 return super(CWConstraint, self).after_deletion_path() |
|
170 |
155 |
171 @property |
156 @property |
172 def type(self): |
157 def type(self): |
173 return self.cstrtype[0].name |
158 return self.cstrtype[0].name |
174 |
159 |
199 return RRQLExpression(self.expression, self.mainvars, self.eid) |
184 return RRQLExpression(self.expression, self.mainvars, self.eid) |
200 |
185 |
201 def check_expression(self, *args, **kwargs): |
186 def check_expression(self, *args, **kwargs): |
202 return self._rqlexpr().check(*args, **kwargs) |
187 return self._rqlexpr().check(*args, **kwargs) |
203 |
188 |
204 def after_deletion_path(self): |
|
205 """return (path, parameters) which should be used as redirect |
|
206 information when this entity is being deleted |
|
207 """ |
|
208 if self.expression_of: |
|
209 return self.expression_of.rest_path(), {} |
|
210 return super(RQLExpression, self).after_deletion_path() |
|
211 |
|
212 |
189 |
213 class CWPermission(AnyEntity): |
190 class CWPermission(AnyEntity): |
214 __regid__ = 'CWPermission' |
191 __regid__ = 'CWPermission' |
215 fetch_attrs, fetch_order = fetch_config(['name', 'label']) |
192 fetch_attrs, fetch_order = fetch_config(['name', 'label']) |
216 |
193 |
217 def dc_title(self): |
194 def dc_title(self): |
218 if self.label: |
195 if self.label: |
219 return '%s (%s)' % (self._cw._(self.name), self.label) |
196 return '%s (%s)' % (self._cw._(self.name), self.label) |
220 return self._cw._(self.name) |
197 return self._cw._(self.name) |
221 |
|
222 def after_deletion_path(self): |
|
223 """return (path, parameters) which should be used as redirect |
|
224 information when this entity is being deleted |
|
225 """ |
|
226 permissionof = getattr(self, 'reverse_require_permission', ()) |
|
227 if len(permissionof) == 1: |
|
228 return permissionof[0].rest_path(), {} |
|
229 return super(CWPermission, self).after_deletion_path() |
|