def set_repo_password(request, repo, password): assert password, 'password must not be none' try: seafserv_threaded_rpc.set_passwd(repo.id, request.user.username, password) except SearpcError, e: if e.msg == 'Bad arguments': return api_error(request, '400') elif e.msg == 'Repo is not encrypted': return api_error(request, '406') elif e.msg == 'Incorrect password': return api_error(request, '402') elif e.msg == 'Internal server error': return api_error(request, '500') else: return api_error(request, '417', "SearpcError:" + e.msg)
def set_repo_password(request, repo, password): assert password, 'password must not be none' try: seafserv_threaded_rpc.set_passwd(repo.id, request.user.username, password) except SearpcError, e: if e.msg == 'Bad arguments': return api_error(status.HTTP_400_BAD_REQUEST, e.msg) elif e.msg == 'Repo is not encrypted': return api_error(status.HTTP_409_CONFLICT, e.msg) elif e.msg == 'Incorrect password': return api_error(status.HTTP_400_BAD_REQUEST, e.msg) elif e.msg == 'Internal server error': return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, e.msg) else: return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, e.msg)
def clean(self): if 'password' in self.cleaned_data: repo_id = self.cleaned_data['repo_id'] username = self.cleaned_data['username'] password = self.cleaned_data['password'] try: seafserv_threaded_rpc.set_passwd(repo_id, username, password) except SearpcError, e: if e.msg == 'Bad arguments': raise forms.ValidationError(_(u'Bad url format')) elif e.msg == 'Incorrect password': raise forms.ValidationError(_(u'Wrong password')) elif e.msg == 'Internal server error': raise forms.ValidationError(_(u'Internal server error')) else: raise forms.ValidationError(_(u'Decrypt library error'))
def clean(self): if 'password' in self.cleaned_data: repo_id = self.cleaned_data['repo_id'] username = self.cleaned_data['username'] password = self.cleaned_data['password'] try: seafserv_threaded_rpc.set_passwd(repo_id, username, password) except SearpcError, e: if e.msg == 'Bad arguments': raise forms.ValidationError(_(u'Bad url format')) # elif e.msg == 'Repo is not encrypted': # return HttpResponseRedirect(reverse('repo', # args=[self.repo_id])) elif e.msg == 'Incorrect password': raise forms.ValidationError(_(u'Wrong password')) elif e.msg == 'Internal server error': raise forms.ValidationError(_(u'Internal server error')) else: raise forms.ValidationError(_(u'Decrypt library error'))