diff --git a/idhub/management/commands/initial_datas.py b/idhub/management/commands/initial_datas.py index 363d7fb..da3539e 100644 --- a/idhub/management/commands/initial_datas.py +++ b/idhub/management/commands/initial_datas.py @@ -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) diff --git a/idhub/models.py b/idhub/models.py index 6b9d0e4..07f9a15 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -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 diff --git a/oidc4vp/models.py b/oidc4vp/models.py index b616c11..8cfdfaf 100644 --- a/oidc4vp/models.py +++ b/oidc4vp/models.py @@ -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, diff --git a/promotion/views.py b/promotion/views.py index 87f2a5e..2ecac4c 100644 --- a/promotion/views.py +++ b/promotion/views.py @@ -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() diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 538fa63..15b9986 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -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)