From 93557fe2776f5f2dcac46fa6c8ce5ded582bd1b9 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 11 Dec 2023 12:11:18 +0100 Subject: [PATCH] form of contract --- idhub/migrations/0001_initial.py | 2 +- idhub_auth/migrations/0001_initial.py | 2 +- oidc4vp/migrations/0001_initial.py | 29 +- promotion/migrations/0001_initial.py | 45 + promotion/models.py | 7 +- promotion/templates/somconnexio_contract.html | 1172 +++++++++++++++- ...il.html => somconnexio_tarifes_mobil.html} | 0 promotion/templates/somconnexio_thanks.html | 1223 +++++++++++++++++ promotion/urls.py | 4 + promotion/views.py | 49 +- 10 files changed, 2492 insertions(+), 41 deletions(-) create mode 100644 promotion/migrations/0001_initial.py rename promotion/templates/{somconnexio.tarifes-mobil.html => somconnexio_tarifes_mobil.html} (100%) create mode 100644 promotion/templates/somconnexio_thanks.html diff --git a/idhub/migrations/0001_initial.py b/idhub/migrations/0001_initial.py index d841426..6d87ae7 100644 --- a/idhub/migrations/0001_initial.py +++ b/idhub/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-12-04 08:44 +# Generated by Django 4.2.5 on 2023-12-11 08:35 from django.conf import settings from django.db import migrations, models diff --git a/idhub_auth/migrations/0001_initial.py b/idhub_auth/migrations/0001_initial.py index 3ee6d7a..f460a62 100644 --- a/idhub_auth/migrations/0001_initial.py +++ b/idhub_auth/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-12-04 08:44 +# Generated by Django 4.2.5 on 2023-12-11 08:35 from django.db import migrations, models diff --git a/oidc4vp/migrations/0001_initial.py b/oidc4vp/migrations/0001_initial.py index 230817d..700c4e8 100644 --- a/oidc4vp/migrations/0001_initial.py +++ b/oidc4vp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-11-29 10:18 +# Generated by Django 4.2.5 on 2023-12-11 08:35 from django.conf import settings from django.db import migrations, models @@ -30,6 +30,7 @@ class Migration(migrations.Migration): 'code', models.CharField(default=oidc4vp.models.set_code, max_length=24), ), + ('code_used', models.BooleanField()), ('created', models.DateTimeField(auto_now=True)), ('presentation_definition', models.CharField(max_length=250)), ], @@ -70,26 +71,6 @@ class Migration(migrations.Migration): ), ], ), - migrations.CreateModel( - name='VPVerifyRequest', - fields=[ - ( - 'id', - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name='ID', - ), - ), - ('nonce', models.CharField(max_length=50)), - ('expected_credentials', models.CharField(max_length=255)), - ('expected_contents', models.TextField()), - ('action', models.TextField()), - ('response_or_redirect', models.CharField(max_length=255)), - ('submitted_on', models.DateTimeField(auto_now=True)), - ], - ), migrations.CreateModel( name='OAuth2VPToken', fields=[ @@ -103,14 +84,14 @@ class Migration(migrations.Migration): ), ), ('created', models.DateTimeField(auto_now=True)), - ('code', models.CharField(max_length=250)), - ('result_verify', models.BooleanField(max_length=250)), - ('presentation_definition', models.CharField(max_length=250)), + ('result_verify', models.CharField(max_length=255)), + ('vp_token', models.TextField()), ( 'authorization', models.ForeignKey( null=True, on_delete=django.db.models.deletion.SET_NULL, + related_name='oauth2vptoken', to='oidc4vp.authorization', ), ), diff --git a/promotion/migrations/0001_initial.py b/promotion/migrations/0001_initial.py new file mode 100644 index 0000000..cbc1f17 --- /dev/null +++ b/promotion/migrations/0001_initial.py @@ -0,0 +1,45 @@ +# Generated by Django 4.2.5 on 2023-12-11 08:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ('oidc4vp', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Promotion', + fields=[ + ( + 'id', + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), + ('name', models.CharField(max_length=250)), + ( + 'discount', + models.PositiveSmallIntegerField( + choices=[(1, 'Financial vulnerability')] + ), + ), + ( + 'authorize', + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name='promotions', + to='oidc4vp.authorization', + ), + ), + ], + ), + ] diff --git a/promotion/models.py b/promotion/models.py index bbf7bbc..2750b79 100644 --- a/promotion/models.py +++ b/promotion/models.py @@ -21,6 +21,9 @@ class Promotion(models.Model): def get_url(self, code): url = "{}?code={}".format( - reverse_lazy("promotion:show_promotion"), + reverse_lazy("promotion:contract"), code - ) \ No newline at end of file + ) + + def get_discount(self, price): + return price - price*0.25 \ No newline at end of file diff --git a/promotion/templates/somconnexio_contract.html b/promotion/templates/somconnexio_contract.html index 251e821..71d0cb2 100644 --- a/promotion/templates/somconnexio_contract.html +++ b/promotion/templates/somconnexio_contract.html @@ -1 +1,1171 @@ -Som Connexió
+ + + + + + + + + + + + + + + Escull la teva tarifa mòbil - Som Connexió + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + Tarifes
+
+ +
+
+
+
+ Persones sòcies 9.257 + Contractes 22.303 +
+ +
+ Blog  |  + Contacte +
+ + + Vols que et truquem? +
+
+skip to Main Content
+
+ + + + + + +
+ +
+ + +
+ + +
+ + + +
+

HOLA HOLA

+ + +
+
+{% load i18n %} +{% load django_bootstrap5 %} +
+{% csrf_token %} +{% if form.errors %} + +{% endif %} +{% bootstrap_form form %} + + +
+
+
+ +
+
    + + Resum + +
  • + Imports inicials +
  • +
  • + Tarjeta SIM {{ sim }}€ +
  • +
  • + Factura mensual +
  • +
  • + {{ mensual }}€ +
  • + Total {{ total }}€ (IVA inclòs) +
+
+
+
+
+ + +
+
+ Vols que et truquem? +
+
+
+
+ +
+
+
+
+ + +
+ +
+ + +
+ + +
+ + + +
+ + + + + + + + + + +
+ + +
+ + + + +Back To Top + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/promotion/templates/somconnexio.tarifes-mobil.html b/promotion/templates/somconnexio_tarifes_mobil.html similarity index 100% rename from promotion/templates/somconnexio.tarifes-mobil.html rename to promotion/templates/somconnexio_tarifes_mobil.html diff --git a/promotion/templates/somconnexio_thanks.html b/promotion/templates/somconnexio_thanks.html new file mode 100644 index 0000000..b3c694f --- /dev/null +++ b/promotion/templates/somconnexio_thanks.html @@ -0,0 +1,1223 @@ + + + + + + + + + + + + + + + Escull la teva tarifa mòbil - Som Connexió + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + Tarifes
+
+ +
+
+
+
+ Persones sòcies 9.257 + Contractes 22.303 +
+ +
+ Blog  |  + Contacte +
+ + + Vols que et truquem? +
+
+skip to Main Content
+
+ + + + + + +
+ +
+ + +
+ + +
+ + + +
+

Contrato

+ + +
+
+Contrato realizado correctamente. Te hemos enviado la información por email. +
+
+ +
+
El més preguntat
+
    +
  • + Mòbil: tarifes i detalls +
    +

    Pots consultar els preus i detalls de les tarifes de mòbil en aquest enllaç.

    +

     

    +
    +
  • +
  • + Quina cobertura de mòbil té Som Connexió? +
    +

    La cobertura del servei és Yoigo/MásMóvil, Orange (4G) i Movistar (3G) i el nostre proveïdor de serveis és MásMóvil.

    +
    +
  • +
  • + Trucades gratuïtes entre mòbils de Som Connexió +
    +

    Les tarifes de mòbil de 0 minuts i 150 minuts inclouen 1.000 minuts de trucades gratuïtes a d’altres telèfons mòbils de Som Connexió (a la tarifa de minuts il·limitats ja estan incloses totes les trucades a mòbils de qualsevol operadora dins l’estat espanyol).

    +

    Això vol dir que si truques a un telèfon mòbil de Som Connexió, els minuts que utilitzis no es descomptaran del teu abonament sinó d’aquests 1.000 minuts.

    +

    Aquesta prestació només s’aplica a la telefonia mòbil de Som Connexió. La telefonia fixa de Som Connexió no inclou aquests minuts, ni en el servei de Fibra ni en el d’ADSL.

    +

    Aquest servei és automàtic. No s’ha de fer res per activar-lo i no es pot desactivar.

    +
    +
  • +
  • + Costos d’alta (mòbil) +
    +

    Quan es fa una alta de servei de telefonia mòbil, afegim a la factura els costos de l’alta del servei: 2,05€ (IVA inclòs)

    +
    +
  • +
  • + Puc mantenir el meu número de mòbil? +
    +

    Sí, sense cap dubte! Se’n diu portabilitat. Però si vols, també es pot canviar.

    +
    +
  • +
  • + Contractar dades addicionals +
    +

    Si esgotes dades abans d’acabar el mes, tens l’opció de contractar dades addicionals que podràs utilitzar fins a acabar el mes:

    +
      +
    • 500 MB (2 €)*
    • +
    • 1 GB (3 €)*
    • +
    • 3 GB (5 €)*
    • +
    • 5 GB (6 €)*
    • +
    • 10 GB (9€)*
    • +
    +

    * IVA inclòs

    +

    Aquí t’expliquem com afegir dades extra.

    +

    Contractar dades addicionals en les tarifes compartides

    +

    Si els mòbils que estan compartint dades esgoten els 50 GB abans que acabi el més, es pot comprar una ampliació de 10 GB per 9€ o de 20 GB per 12€ que podran consumir els diferents mòbils. Aquí t’expliquem com afegir dades extra a les tarifes compartides.

    +
    +
  • +
  • + Preus SMS +
    +

    Els SMS tenen un preu de 0,10€/sms

    +

    IMPORTANT: els SMS no estan inclosos a cap de les tarifes de Som Connexió. Tampoc a la tarifa de minuts il·limitats.

    +
    +
  • +
  • + Preus de trucades fora de tarifa des del mòbil +
    +

    Aquests són els preus de les trucades un cop has superat els minuts que tens contractats a la teva tarifa:

    +

    0,18€ per l’establiment de la trucada, que inclou els 5 primers minuts de la conversa.

    +

    A partir del minut 6, es paga 0,036€/min.

    +

    Consulta les tarifes de roaming AQUÍ.

    +
    +
  • +
  • + Tarifa bàsica mòbil: 0 min i 0 Gb +
    +

    Amb un cost base de 2€ mensuals, es tracta d’un consum “a granel”, és a dir, que es paga per minut i per unitat de dades consumides.

    +

    Aquesta tarifa és adequada per a persones que utilitzen el mòbil per estar localitzables i fer una trucada molt puntualment (només surt a compte si es fan menys de 6 trucades al mes de curta durada) i no utilitza el mòbil per connectar-se a Internet o ho fa de una manera molt esporàdica.

    +

    El preu per trucada en aquest abonament és de 0,18€ per l’establiment de la trucada, que inclou els 5 primers minuts de la conversa. A partir del minut 6, es paga 0,036€/min

    +

    El preu del servei de dades quan no s’ha contractat cap abonament és de 0,036€/Mb

    +

    Si vols desactivar el servei de dades, ens ho has de sol·licitar a serveis@somconnexio.coop.

    +
    +
  • +
  • + NÚMEROS DE TARIFACIÓ ESPECIAL +
    +

    Els preus estàndard de veu o missatges exclouen:

    +
      +
    • Els serveis de tarifació especial (per exemple: 80x, 90x o SMS Premium). Mira la taula de tarifes AQUÍ
    • +
    • Trànsit internacional
    • +
    • Trànsit en itinerància
    • +
    +

    Alguns dels serveis de tarifació especial de cost elevat estan bloquejats per defecte. Per tenir més informació sobre l’opció de bloqueig dels números de cost especial, consulta aquesta TAULA.

    +

    En aquest enllaç de la OCU ens donen més informació sobre els números de tarificació especial.

    +
    +
  • +
+
+
+
+
+ + +
+
+ Vols que et truquem? +
+
+
+
+ +
+
+
+
+ + +
+ +
+ + +
+ + +
+ + + +
+ + + + + + + + + + +
+ + +
+ + + + +Back To Top + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/promotion/urls.py b/promotion/urls.py index 8fd5eb7..2925480 100644 --- a/promotion/urls.py +++ b/promotion/urls.py @@ -11,4 +11,8 @@ urlpatterns = [ name="show_promotion"), path('select_wallet', views.SelectWalletView.as_view(), name="select_wallet"), + path('contract', views.ContractView.as_view(), + name="contract"), + path('contract/1', views.ThanksView.as_view(), + name="thanks"), ] diff --git a/promotion/views.py b/promotion/views.py index dcde3f0..0ed4455 100644 --- a/promotion/views.py +++ b/promotion/views.py @@ -6,11 +6,21 @@ from django.template.loader import get_template from django.urls import reverse_lazy from django.http import HttpResponse +from oidc4vp.models import Authorization from promotion.forms import WalletForm, ContractForm class PromotionView(View): - template_name = "somconnexio.tarifes-mobil.html" + template_name = "somconnexio_tarifes-mobil.html" + def get(self, request, *args, **kwargs): + self.context = {} + template = get_template( + self.template_name, + ).render() + return HttpResponse(template) + +class ThanksView(View): + template_name = "somconnexio_thanks.html" def get(self, request, *args, **kwargs): self.context = {} template = get_template( @@ -19,26 +29,38 @@ class PromotionView(View): return HttpResponse(template) -class PromotionMobile1View(FormView): +class ContractView(FormView): template_name = "somconnexio_contract.html" promotion = None - vp_tokens = None + vp_token = None authorization = None form_class = ContractForm - def get(self, request, *args, **kwargs): + success_url = reverse_lazy('promotion:thanks') + + def get_context_data(self, **kwargs): + # import pdb; pdb.set_trace() + self.context = super().get_context_data(**kwargs) code = self.request.GET.get("code") self.get_discount(code) - self.context = { + self.context.update({ "promotion": self.promotion, - "verificable_presentation": self.vp_token - } - template = get_template( - self.template_name, - ).render() - return HttpResponse(template) - + "verificable_presentation": self.vp_token, + "sim": 10.0, + "mensual": 15.0, + "total": 25.0 + }) + if self.promotion: + self.context['sim'] = self.context.get_discount(self.context["sim"]) + self.context['mensual'] = self.context.get_discount(self.context["mensual"]) + self.context['total'] = self.context.get_discount(self.context["total"]) + return self.context + + def get_form_kwargs(self): kwargs = super().get_form_kwargs() + if not self.vp_token: + return kwargs + self.vp_token.get_user_info() kwargs['verificable_presentation'] = self.vp_token kwargs["nif"] = self.vp_token.user_info.get("nif", '') @@ -58,6 +80,9 @@ class PromotionMobile1View(FormView): return redirect(url) def get_discount(self, code): + if not code: + return + self.authorization = Authorization.objects.filter( code=code, code_unused=False