def get_readonly_fields(self): readonly_fields = ModelFields.get_readonly_fields(self) # 只能首次修改 if self.instance.pk and has_permit(self.crt_user, 'liantang.-only_first_edit'): readonly_fields.extend(['state', 'date', 'desp']) return readonly_fields
def can_access(self): """ superuser 不会调用该函数,所以这里不用考虑superuser 不允许修改另外的评论 """ access = super(CommentForm, self).can_access() if has_permit(self.crt_user, 'comment.all'): return access else: if self.instance.emp.user != self.crt_user: return False else: return True
def getExtraHead(self): return [ { 'name': 'agent__name', 'label': '代理人', 'editor': 'com-filter-text', 'visible': not has_permit(self.crt_user, '-agent_constraint') }, ]
def get_context(self): ctx = ModelFields.get_context(self) if has_permit(self.crt_user, 'liantang.-only_add'): ctx['only_add'] = True return ctx
def names(self): names_ = ['player__acount', 'block'] if not has_permit(self.crt_user, '-agent_constraint'): names_.append('agent__name') return names_
def inn_filter(self, query): if has_permit(self.crt_user, '-agent_constraint'): query = query.filter(agent__account=self.crt_user) return query
def clean(self): cleaned_data = super(WorkRecordForm,self).clean() if not has_permit(self.crt_user,'workrecord.check_all'): if self.instance.status!='waiting': raise forms.ValidationError('you have no permition to edit this workrecord again')