add main to organization

This commit is contained in:
Cayo Puigdefabregas 2024-02-27 09:27:55 +01:00
parent 35c04b0e39
commit 27f84c30e7
5 changed files with 11 additions and 22 deletions

View file

@ -35,9 +35,6 @@ class Command(BaseCommand):
for r in f:
self.create_organizations(r[0].strip(), r[1].strip())
# You need to confirm than your Organization is created
assert Organization.objects.filter(name=settings.ORGANIZATION).exists()
if settings.SYNC_ORG_DEV == 'y':
self.sync_credentials_organizations("pangea.org", "somconnexio.coop")
self.sync_credentials_organizations("local 8000", "local 9000")
@ -55,7 +52,10 @@ class Command(BaseCommand):
def create_organizations(self, name, url):
Organization.objects.create(name=name, response_uri=url)
if url == settings.RESPONSE_URI:
Organization.objects.create(name=name, response_uri=url, main=True)
else:
Organization.objects.create(name=name, response_uri=url)
def sync_credentials_organizations(self, test1, test2):
org1 = Organization.objects.get(name=test1)

View file

@ -475,7 +475,7 @@ class DID(models.Model):
return json.loads(self.key_material)
def get_organization(self):
return Organization.objects.get(name=settings.ORGANIZATION)
return Organization.objects.get(main=True)
class Schemas(models.Model):
type = models.CharField(max_length=250)
@ -697,6 +697,8 @@ class VerificableCredential(models.Model):
sid
)
org = Organization.objects.get(main=True)
context = {
'id_credential': str(self.id),
'vc_id': url_id,
@ -706,7 +708,7 @@ class VerificableCredential(models.Model):
'firstName': self.user.first_name or "",
'lastName': self.user.last_name or "",
'email': self.user.email,
'organisation': settings.ORGANIZATION or '',
'organisation': org.name or '',
}
context.update(d)
return context

View file

@ -47,9 +47,11 @@ class Organization(models.Model):
want to connect to this organization. (send a request)
For use the packages requests we need use my_client_id
For use in the get or post method of a View, then we need use client_id
and secret_id
and secret_id.
main is a field which indicates the organization of this idhub
"""
name = models.CharField(max_length=250)
main = models.BooleanField(default=False)
client_id = models.CharField(
max_length=24,
default=set_client_id,

View file

@ -104,20 +104,6 @@ class SelectWalletView(FormView):
template_name = "select_wallet.html"
form_class = WalletForm
success_url = reverse_lazy('promotion:select_wallet')
def get(self, request, *args, **kwargs):
if settings.ORGANIZATION == 'Setem':
self.template_name = "select_wallet_setem.html"
return super().get(request, *args, **kwargs)
# self.context = {'form': fo}
# template = get_template(
# self.template_name,
# # context
# ).render()
# return HttpResponse(template)
# def post(self, request, *args, **kwargs):
# super().post(request, *args, **kwargs)
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()

View file

@ -220,7 +220,6 @@ LOGGING = {
}
}
ORGANIZATION = config('ORGANIZATION', 'Pangea')
SYNC_ORG_DEV = config('SYNC_ORG_DEV', 'y')
ORG_FILE = config('ORG_FILE', 'examples/organizations.csv')
ENABLE_EMAIL = config('ENABLE_EMAIL', default=True, cast=bool)