def clean_group_name(self): group_name = self.cleaned_data["group_name"] if not validate_group_name(group_name): error_msg = _(u"Group name can only contain letters, numbers or underscore") raise forms.ValidationError(error_msg) else: return group_name
def org_groups(request, url_prefix): """ List org groups and add org group. """ org = get_user_current_org(request.user.username, url_prefix) if not org: return HttpResponseRedirect(reverse(myhome)) if request.method == "POST": result = {} content_type = "application/json; charset=utf-8" group_name = request.POST.get("group_name") if not validate_group_name(group_name): result["error"] = _(u"Group name can only contain letters, digits and underscore") return HttpResponse(json.dumps(result), content_type=content_type) try: e_grpname = group_name.encode("utf-8") user = request.user.username group_id = ccnet_threaded_rpc.create_org_group(org.org_id, e_grpname, user) except SearpcError, e: result["error"] = _(e.msg) return HttpResponse(json.dumps(result), content_type=content_type) return HttpResponse(json.dumps({"success": True}), content_type=content_type)
def clean_group_name(self): group_name = self.cleaned_data['group_name'] if not validate_group_name(group_name): error_msg = _(u'Group name can only contain letters, numbers or underscore') raise forms.ValidationError(error_msg) else: return group_name
def clean_nickname(self): nickname = self.cleaned_data['nickname'] if validate_group_name(nickname): return nickname else: raise forms.ValidationError(_(u'Nickname can only contain characters, numbers or underscore.'))