def register(**kwargs): """ Method turns keyword arguments (which describe user) into a dictionary and registers the user by \c XMLRPC and """ if ('recaptcha' in kwargs): kwargs.pop('recaptcha') kwargs['wi_data'] = settings.WI_DATA return make_request('guest/user/register/', kwargs)
def authenticate(username, password): """ Method for authentication. When successful, it returns \c user object. """ response = make_request('guest/user/check_password/', {'login': username, 'password': password}) if response['status'] == 'ok' and response['data']: return parse_user(response['data']) return None
def activate(activation_key): """ Method checks, if \c activation_key is ok. If so, it activates user. """ if SHA1_RE.search(activation_key): response = make_request('guest/user/activate/', {'act_key': activation_key, 'wi_data': settings.WI_DATA}) if response['status'] == 'ok': return response return False
def clean_login(self): """ Validate that the login is alphanumeric and is not already in use. """ response = make_request("guest/user/exists/", {"login": self.cleaned_data["login"]}) if response["data"] == False: return self.cleaned_data["login"] else: raise forms.ValidationError(_("A user with that login already exists."))
def clean_email(self): """ Validate that the supplied email address is unique for the site. """ response = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']}) if response['data'] == False: return self.cleaned_data['email'] else: raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
def clean_login(self): """ Validate that the login is alphanumeric and is not already in use. """ response = make_request('guest/user/exists/', {'login': self.cleaned_data['login']}) if response['data'] == False: return self.cleaned_data['login'] else: raise forms.ValidationError(_("A user with that login already exists."))
def cm_authenticate(user, password, cm_id): """ CM admin authentication. Returns True if successful. @parameter{user} @parameter{password} @parameter{cm_id} """ rest_data = make_request('user/admin/check_password/', {'cm_password': password}, user=user) return True if rest_data['status'] == 'ok' else False
def clean_email(self): """ Validates that a user exists with the given e-mail address. """ email = self.cleaned_data["email"] rest_data = make_request("guest/user/email_exists/", {"email": email}) if rest_data["status"] == "ok" and rest_data["data"] == False: raise forms.ValidationError(_("Incorrect email address.")) return email
def clean_old_password(self): """ Validates that the old_password field is correct. """ self.cleaned_data['old_password'] = hashlib.sha1(self.cleaned_data['old_password']).hexdigest() old_password = self.cleaned_data["old_password"] rest_data = make_request('guest/user/check_password/', {'login': self.user.username, 'password': old_password}) if rest_data['status'] == 'ok' and rest_data['data'] == False: raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again.")) return old_password
def clean_email(self): """ Validates that a user exists with the given e-mail address. """ email = self.cleaned_data['email'] rest_data = make_request('guest/user/email_exists/', {'email': email}) if rest_data['status'] == 'ok' and rest_data['data'] == False: raise forms.ValidationError(_('Incorrect email address.')) return email
def clean_old_password(self): """ Validates that the old_password field is correct. """ self.cleaned_data["old_password"] = hashlib.sha1(self.cleaned_data["old_password"]).hexdigest() old_password = self.cleaned_data["old_password"] rest_data = make_request("guest/user/check_password/", {"login": self.user.username, "password": old_password}) if rest_data["status"] == "ok" and rest_data["data"] == False: raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again.")) return old_password
def authenticate(username, password): """ Method for authentication. When successful, it returns \c user object. """ response = make_request('guest/user/check_password/', { 'login': username, 'password': password }) if response['status'] == 'ok' and response['data']: return parse_user(response['data']) return None
def activate(activation_key): """ Method checks, if \c activation_key is ok. If so, it activates user. """ if SHA1_RE.search(activation_key): response = make_request('guest/user/activate/', { 'act_key': activation_key, 'wi_data': settings.WI_DATA }) if response['status'] == 'ok': return response return False
def clean_email(self): """ Validate that the supplied email address is unique for the site. """ # if same email as current if self.old_email == self.cleaned_data['email']: return self.cleaned_data['email'] rest_data = make_request('guest/user/email_exists/', {'email': self.cleaned_data['email']}) if rest_data['data']: raise forms.ValidationError(_("This email address is already in use. Please supply a different email address.")) else: return self.cleaned_data['email']
def clean(self): """ Checks if there is enough space on CM. """ if not self.cleaned_data.get('count') or not self.cleaned_data.get('worker_template_id') or not self.cleaned_data.get('head_template_id'): return None response = make_request('user/farm/check_resources/', {'count': self.cleaned_data.get('count'), 'template_id': self.cleaned_data.get('worker_template_id'), 'head_template_id': self.cleaned_data.get('head_template_id') }, user=self.session['user']) if response['status'] == 'ok' and response['data'] == False: raise forms.ValidationError(_("Not enough resources. Choose smaller farm or try again later.")) else: return self.cleaned_data
def clean(self): """ Checks if there is enough space on CM. """ if not self.cleaned_data.get('count') or not self.cleaned_data.get( 'worker_template_id') or not self.cleaned_data.get( 'head_template_id'): return None response = make_request( 'user/farm/check_resources/', { 'count': self.cleaned_data.get('count'), 'template_id': self.cleaned_data.get('worker_template_id'), 'head_template_id': self.cleaned_data.get('head_template_id') }, user=self.session['user']) if response['status'] == 'ok' and response['data'] == False: raise forms.ValidationError( _("Not enough resources. Choose smaller farm or try again later." )) else: return self.cleaned_data