fix 184 comunication with user, need credentials
This commit is contained in:
parent
0eec5d40a1
commit
fd27e82203
|
@ -20,6 +20,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if form.if_credentials %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
{% bootstrap_form form %}
|
{% bootstrap_form form %}
|
||||||
|
@ -29,6 +30,12 @@
|
||||||
<a class="btn btn-grey" href="{% url 'idhub:user_credentials' %}">{% trans "Cancel" %}</a>
|
<a class="btn btn-grey" href="{% url 'idhub:user_credentials' %}">{% trans "Cancel" %}</a>
|
||||||
<input class="btn btn-green-user" type="submit" name="submit" value="{% trans 'Request' %}" />
|
<input class="btn btn-green-user" type="submit" name="submit" value="{% trans 'Request' %}" />
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-4">
|
||||||
|
{% trans 'Sorry no there are credentials enabled' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -86,6 +86,7 @@ class RequestCredentialForm(forms.Form):
|
||||||
self.user = kwargs.pop('user', None)
|
self.user = kwargs.pop('user', None)
|
||||||
self.lang = kwargs.pop('lang', None)
|
self.lang = kwargs.pop('lang', None)
|
||||||
self._domain = kwargs.pop('domain', None)
|
self._domain = kwargs.pop('domain', None)
|
||||||
|
self.if_credentials = kwargs.pop('if_credentials', None)
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['did'].choices = [
|
self.fields['did'].choices = [
|
||||||
(x.did, x.label) for x in DID.objects.filter(user=self.user)
|
(x.did, x.label) for x in DID.objects.filter(user=self.user)
|
||||||
|
|
|
@ -392,18 +392,26 @@ class CredentialsRequestView(MyWallet, FormView):
|
||||||
form_class = RequestCredentialForm
|
form_class = RequestCredentialForm
|
||||||
success_url = reverse_lazy('idhub:user_credentials')
|
success_url = reverse_lazy('idhub:user_credentials')
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
response = super().get(request, *args, **kwargs)
|
response = super().get(*args, **kwargs)
|
||||||
if not cache.get("KEY_DIDS"):
|
if not DID.objects.filter(user=self.request.user).exists():
|
||||||
return redirect(reverse_lazy('idhub:user_waiting'))
|
return redirect(reverse_lazy('idhub:user_dids_new'))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
self.if_credentials = VerificableCredential.objects.filter(
|
||||||
|
user=self.request.user,
|
||||||
|
status=VerificableCredential.Status.ENABLED.value,
|
||||||
|
).exists()
|
||||||
|
|
||||||
kwargs['user'] = self.request.user
|
kwargs['user'] = self.request.user
|
||||||
kwargs['lang'] = self.request.LANGUAGE_CODE
|
kwargs['lang'] = self.request.LANGUAGE_CODE
|
||||||
domain = "{}://{}".format(self.request.scheme, self.request.get_host())
|
domain = "{}://{}".format(self.request.scheme, self.request.get_host())
|
||||||
kwargs['domain'] = domain
|
kwargs['domain'] = domain
|
||||||
|
kwargs['if_credentials'] = self.if_credentials
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -433,17 +441,19 @@ class DemandAuthorizationView(MyWallet, FormView):
|
||||||
user=self.request.user,
|
user=self.request.user,
|
||||||
status=VerificableCredential.Status.ENABLED.value,
|
status=VerificableCredential.Status.ENABLED.value,
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
if not self.if_credentials and creds_enable:
|
if not self.if_credentials and creds_enable:
|
||||||
return redirect(reverse_lazy('idhub:user_credentials_request'))
|
return redirect(reverse_lazy('idhub:user_credentials_request'))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
kwargs['user'] = self.request.user
|
|
||||||
self.if_credentials = VerificableCredential.objects.filter(
|
self.if_credentials = VerificableCredential.objects.filter(
|
||||||
user=self.request.user,
|
user=self.request.user,
|
||||||
status=VerificableCredential.Status.ISSUED.value,
|
status=VerificableCredential.Status.ISSUED.value,
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
|
kwargs['user'] = self.request.user
|
||||||
kwargs['if_credentials'] = self.if_credentials
|
kwargs['if_credentials'] = self.if_credentials
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue