def clean_username(self): username = strip(self.cleaned_data['username']) if not username: raise forms.ValidationError(_('User name is needed')) if not UserInfo.objects.filter(username=username).exists(): raise forms.ValidationError(_('This user doesn\'t exists')) return username
def info(self): return { 'pk': self.pk, 'tag': (self.tag or '').split(' '), 'uid': self.user.pk, 'uname': self.user.username, 'visit': self.visit, 'like': self.like, 'follow': self.follow, 'title': strip((self.resume or '').split('\n')[0].split('\r')[0].split('\r\n')[0]), }
def clean_tips(self): """ Clean for tips """ tips = strip(self.cleaned_data['tips']) if not tips: raise forms.ValidationError(_('Tips is needed')) t = Tips.objects.filter(tips=tips) if t.exists(): ut = UserTips.objects.filter(tips=t, user=getUI(getUsr(self.request))) if ut.exists(): raise forms.ValidationError(_('This tip has already record by you')) return tips return tips
def clean_api(self): """ Clean for api """ api = strip(self.cleaned_data['api']) if not api: raise forms.ValidationError(_('Api is needed')) a = ApiInfo.objects.filter(api=api) if a.exists(): ua = UserApiInfo.objects.filter(api=a, user=getUI(getUsr(self.request))) if ua.exists(): raise forms.ValidationError(_('This api has already record by you')) return api return api
def clean_tag(self): """ Clean for tag """ tag = strip(self.cleaned_data['tag']) or '' return ' '.join([strip(t) for t in tag.split(' ')])
def save_model(self, request, obj, form, change): obj.wepush_id = strip(obj.wepush_id) obj.openid = strip(obj.openid) obj.save()
def save_model(self, request, obj, form, change): obj.app_id = strip(obj.app_id) obj.app_secret = strip(obj.app_secret) obj.template_id = strip(obj.template_id) obj.token_url = strip(obj.token_url) obj.save()
def clean_password(self): password = strip(self.cleaned_data['password']) if not password: raise forms.ValidationError(_('Password is needed')) return hashlib.md5(password).hexdigest()