simplify flow from promotion web
This commit is contained in:
parent
8abb43f95d
commit
cb1b7de4f6
|
@ -144,6 +144,9 @@ class CredentialsRequestView(MyWallet, FormView):
|
|||
messages.success(self.request, _("The credential was issued successfully!"))
|
||||
Event.set_EV_CREDENTIAL_ISSUED_FOR_USER(cred)
|
||||
Event.set_EV_CREDENTIAL_ISSUED(cred)
|
||||
url = self.request.session.pop('next_url', None)
|
||||
if url:
|
||||
return redirect(url)
|
||||
else:
|
||||
messages.error(self.request, _("The credential does not exist!"))
|
||||
return super().form_valid(form)
|
||||
|
|
|
@ -23,8 +23,10 @@ class AuthorizeForm(forms.Form):
|
|||
|
||||
reg = r'({})'.format('|'.join(self.presentation_definition))
|
||||
|
||||
self.credentials = self.user.vcredentials.filter(
|
||||
self.all_credentials = self.user.vcredentials.filter(
|
||||
schema__type__iregex=reg,
|
||||
)
|
||||
self.credentials = self.all_credentials.filter(
|
||||
status=VerificableCredential.Status.ISSUED.value
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -27,6 +27,12 @@ class AuthorizeView(UserView, FormView):
|
|||
form_class = AuthorizeForm
|
||||
success_url = reverse_lazy('idhub:user_demand_authorization')
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
response = super().get(request, *args, **kwargs)
|
||||
if self.request.session.get('next_url'):
|
||||
return redirect(reverse_lazy('idhub:user_credentials_request'))
|
||||
return response
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['user'] = self.request.user
|
||||
|
@ -38,6 +44,12 @@ class AuthorizeView(UserView, FormView):
|
|||
kwargs["org"] = self.get_org()
|
||||
kwargs["code"] = self.request.GET.get('code')
|
||||
return kwargs
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = super().get_form(form_class=form_class)
|
||||
if form.all_credentials.exists() and not form.credentials.exists():
|
||||
self.request.session['next_url'] = self.request.get_full_path()
|
||||
return form
|
||||
|
||||
def form_valid(self, form):
|
||||
authorization = form.save()
|
||||
|
|
Loading…
Reference in a new issue