add more translate sentens
This commit is contained in:
parent
9ae75b00ab
commit
b4b55a811d
|
@ -139,7 +139,7 @@ class ImportForm(forms.Form):
|
|||
|
||||
|
||||
class SchemaForm(forms.Form):
|
||||
file_template = forms.FileField()
|
||||
file_template = forms.FileField(label=_("File template"))
|
||||
|
||||
|
||||
class MembershipForm(forms.ModelForm):
|
||||
|
|
|
@ -629,6 +629,7 @@ class UserRol(models.Model):
|
|||
)
|
||||
service = models.ForeignKey(
|
||||
Service,
|
||||
verbose_name=_("Service"),
|
||||
on_delete=models.CASCADE,
|
||||
related_name='users',
|
||||
)
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
<h1 class="h2">{{ title }}</h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<div class="btn-group me-2">
|
||||
<input class="form-control form-control-grey " type="text" placeholder="Search" aria-label="Search">
|
||||
<input class="form-control form-control-grey " type="text" placeholder="{% trans 'Search' %}" aria-label="Search">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
<h1 class="h2">{{ title }}</h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<div class="btn-group me-2">
|
||||
<input class="form-control form-control-grey " type="text" placeholder="Search" aria-label="Search">
|
||||
<input class="form-control form-control-grey " type="text" placeholder="{% trans 'Search' %}" aria-label="Search">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -88,9 +88,6 @@ urlpatterns = [
|
|||
path('user/credentials_presentation/demand',
|
||||
views_user.DemandAuthorizationView.as_view(),
|
||||
name='user_demand_authorization'),
|
||||
path('user/credentials_presentation/',
|
||||
views_user.CredentialsPresentationView.as_view(),
|
||||
name='user_credentials_presentation'),
|
||||
|
||||
# Admin
|
||||
path('admin/dashboard/', views_admin.DashboardView.as_view(),
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import requests
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from idhub_auth.models import User
|
||||
from idhub.models import DID, VerificableCredential
|
||||
from oidc4vp.models import Organization
|
||||
|
@ -15,8 +17,8 @@ class ProfileForm(forms.ModelForm):
|
|||
|
||||
|
||||
class RequestCredentialForm(forms.Form):
|
||||
did = forms.ChoiceField(choices=[])
|
||||
credential = forms.ChoiceField(choices=[])
|
||||
did = forms.ChoiceField(label=_("Did"), choices=[])
|
||||
credential = forms.ChoiceField(label=_("Credential"), choices=[])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user', None)
|
||||
|
@ -59,7 +61,7 @@ class RequestCredentialForm(forms.Form):
|
|||
|
||||
|
||||
class DemandAuthorizationForm(forms.Form):
|
||||
organization = forms.ChoiceField(choices=[])
|
||||
organization = forms.ChoiceField(label=_("Organization"), choices=[])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user', None)
|
||||
|
@ -85,42 +87,3 @@ class DemandAuthorizationForm(forms.Form):
|
|||
|
||||
return
|
||||
|
||||
|
||||
class CredentialPresentationForm(forms.Form):
|
||||
organization = forms.ChoiceField(choices=[])
|
||||
# credential = forms.ChoiceField(choices=[])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user', None)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['organization'].choices = [
|
||||
(x.id, x.name) for x in Organization.objects.filter()
|
||||
]
|
||||
# self.fields['credential'].choices = [
|
||||
# (x.id, x.type()) for x in VerificableCredential.objects.filter(
|
||||
# user=self.user,
|
||||
# status=VerificableCredential.Status.ISSUED
|
||||
# )
|
||||
# ]
|
||||
|
||||
def save(self, commit=True):
|
||||
self.org = Organization.objects.filter(
|
||||
id=self.data['organization']
|
||||
)
|
||||
self.cred = VerificableCredential.objects.filter(
|
||||
user=self.user,
|
||||
id=self.data['credential'],
|
||||
status=VerificableCredential.Status.ISSUED
|
||||
)
|
||||
if not all([self.org.exists(), self.cred.exists()]):
|
||||
return
|
||||
|
||||
self.org = self.org[0]
|
||||
self.cred = self.cred[0]
|
||||
|
||||
if commit:
|
||||
self.org.send(self.cred)
|
||||
return self.cred
|
||||
|
||||
return
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ from django.contrib import messages
|
|||
from idhub.user.forms import (
|
||||
ProfileForm,
|
||||
RequestCredentialForm,
|
||||
CredentialPresentationForm,
|
||||
DemandAuthorizationForm
|
||||
)
|
||||
from idhub.mixins import UserView
|
||||
|
@ -181,30 +180,6 @@ class DemandAuthorizationView(MyWallet, FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
|
||||
class CredentialsPresentationView(MyWallet, FormView):
|
||||
template_name = "idhub/user/credentials_presentation.html"
|
||||
subtitle = _('Credential presentation')
|
||||
icon = 'bi bi-patch-check-fill'
|
||||
form_class = CredentialPresentationForm
|
||||
success_url = reverse_lazy('idhub:user_credentials')
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['user'] = self.request.user
|
||||
kwargs['authorize'] = self.request.GET.params.get("uri")
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
cred = form.save()
|
||||
if cred:
|
||||
Event.set_EV_CREDENTIAL_PRESENTED_BY_USER(cred, form.org)
|
||||
Event.set_EV_CREDENTIAL_PRESENTED(cred, form.org)
|
||||
messages.success(self.request, _("The credential was presented successfully!"))
|
||||
else:
|
||||
messages.error(self.request, _("Error sending credential!"))
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class DidsView(MyWallet, TemplateView):
|
||||
template_name = "idhub/user/dids.html"
|
||||
subtitle = _('Identities (DIDs)')
|
||||
|
|
|
@ -6,15 +6,12 @@ from idhub_auth.models import User
|
|||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
first_name = forms.CharField(label=_("First name"), required=True)
|
||||
last_name = forms.CharField(label=_("Last name"), required=True)
|
||||
first_name = forms.CharField(required=True)
|
||||
last_name = forms.CharField(required=True)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['first_name', 'last_name', 'email']
|
||||
labels = {
|
||||
'email': _('Email address'),
|
||||
}
|
||||
|
||||
def clean_first_name(self):
|
||||
first_name = super().clean()['first_name']
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
|
||||
|
||||
|
||||
|
@ -35,14 +36,14 @@ class UserManager(BaseUserManager):
|
|||
|
||||
class User(AbstractBaseUser):
|
||||
email = models.EmailField(
|
||||
verbose_name="email address",
|
||||
_('Email address'),
|
||||
max_length=255,
|
||||
unique=True,
|
||||
)
|
||||
is_active = models.BooleanField(default=True)
|
||||
is_admin = models.BooleanField(default=False)
|
||||
first_name = models.CharField(max_length=255, blank=True, null=True)
|
||||
last_name = models.CharField(max_length=255, blank=True, null=True)
|
||||
first_name = models.CharField(_("First name"), max_length=255, blank=True, null=True)
|
||||
last_name = models.CharField(_("Last name"), max_length=255, blank=True, null=True)
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
|
|
Loading…
Reference in a new issue