add more translate sentens

This commit is contained in:
Cayo Puigdefabregas 2023-12-14 17:59:40 +01:00
parent 9ae75b00ab
commit b4b55a811d
9 changed files with 15 additions and 81 deletions

View File

@ -139,7 +139,7 @@ class ImportForm(forms.Form):
class SchemaForm(forms.Form): class SchemaForm(forms.Form):
file_template = forms.FileField() file_template = forms.FileField(label=_("File template"))
class MembershipForm(forms.ModelForm): class MembershipForm(forms.ModelForm):

View File

@ -629,6 +629,7 @@ class UserRol(models.Model):
) )
service = models.ForeignKey( service = models.ForeignKey(
Service, Service,
verbose_name=_("Service"),
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name='users', related_name='users',
) )

View File

@ -139,7 +139,7 @@
<h1 class="h2">{{ title }}</h1> <h1 class="h2">{{ title }}</h1>
<div class="btn-toolbar mb-2 mb-md-0"> <div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2"> <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> </div>
</div> </div>

View File

@ -171,7 +171,7 @@
<h1 class="h2">{{ title }}</h1> <h1 class="h2">{{ title }}</h1>
<div class="btn-toolbar mb-2 mb-md-0"> <div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2"> <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> </div>
</div> </div>

View File

@ -88,9 +88,6 @@ urlpatterns = [
path('user/credentials_presentation/demand', path('user/credentials_presentation/demand',
views_user.DemandAuthorizationView.as_view(), views_user.DemandAuthorizationView.as_view(),
name='user_demand_authorization'), name='user_demand_authorization'),
path('user/credentials_presentation/',
views_user.CredentialsPresentationView.as_view(),
name='user_credentials_presentation'),
# Admin # Admin
path('admin/dashboard/', views_admin.DashboardView.as_view(), path('admin/dashboard/', views_admin.DashboardView.as_view(),

View File

@ -1,6 +1,8 @@
import requests import requests
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.utils.translation import gettext_lazy as _
from idhub_auth.models import User from idhub_auth.models import User
from idhub.models import DID, VerificableCredential from idhub.models import DID, VerificableCredential
from oidc4vp.models import Organization from oidc4vp.models import Organization
@ -15,8 +17,8 @@ class ProfileForm(forms.ModelForm):
class RequestCredentialForm(forms.Form): class RequestCredentialForm(forms.Form):
did = forms.ChoiceField(choices=[]) did = forms.ChoiceField(label=_("Did"), choices=[])
credential = forms.ChoiceField(choices=[]) credential = forms.ChoiceField(label=_("Credential"), choices=[])
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None) self.user = kwargs.pop('user', None)
@ -59,7 +61,7 @@ class RequestCredentialForm(forms.Form):
class DemandAuthorizationForm(forms.Form): class DemandAuthorizationForm(forms.Form):
organization = forms.ChoiceField(choices=[]) organization = forms.ChoiceField(label=_("Organization"), choices=[])
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None) self.user = kwargs.pop('user', None)
@ -85,42 +87,3 @@ class DemandAuthorizationForm(forms.Form):
return 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

View File

@ -15,7 +15,6 @@ from django.contrib import messages
from idhub.user.forms import ( from idhub.user.forms import (
ProfileForm, ProfileForm,
RequestCredentialForm, RequestCredentialForm,
CredentialPresentationForm,
DemandAuthorizationForm DemandAuthorizationForm
) )
from idhub.mixins import UserView from idhub.mixins import UserView
@ -181,30 +180,6 @@ class DemandAuthorizationView(MyWallet, FormView):
return super().form_valid(form) 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): class DidsView(MyWallet, TemplateView):
template_name = "idhub/user/dids.html" template_name = "idhub/user/dids.html"
subtitle = _('Identities (DIDs)') subtitle = _('Identities (DIDs)')

View File

@ -6,15 +6,12 @@ from idhub_auth.models import User
class ProfileForm(forms.ModelForm): class ProfileForm(forms.ModelForm):
first_name = forms.CharField(label=_("First name"), required=True) first_name = forms.CharField(required=True)
last_name = forms.CharField(label=_("Last name"), required=True) last_name = forms.CharField(required=True)
class Meta: class Meta:
model = User model = User
fields = ['first_name', 'last_name', 'email'] fields = ['first_name', 'last_name', 'email']
labels = {
'email': _('Email address'),
}
def clean_first_name(self): def clean_first_name(self):
first_name = super().clean()['first_name'] first_name = super().clean()['first_name']

View File

@ -1,4 +1,5 @@
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
@ -35,14 +36,14 @@ class UserManager(BaseUserManager):
class User(AbstractBaseUser): class User(AbstractBaseUser):
email = models.EmailField( email = models.EmailField(
verbose_name="email address", _('Email address'),
max_length=255, max_length=255,
unique=True, unique=True,
) )
is_active = models.BooleanField(default=True) is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False) is_admin = models.BooleanField(default=False)
first_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(max_length=255, blank=True, null=True) last_name = models.CharField(_("Last name"), max_length=255, blank=True, null=True)
objects = UserManager() objects = UserManager()