From 01214a785959878f6d7dd835347819dbaa888ac1 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 2 Jun 2023 10:37:42 -0500 Subject: Add support for digital signature providers This adds a new type of provider to the system for handling digital signatures. Initially the only consumer is conference sponsorships, but it could be added for other parts of the system as well in the future. Regular "old-style" sponsorship contracts are still supported, but will gain the feature to auto-fill sponsor name and VAT number if wanted. The sponsor signup workflow is adjusted to support either one or both of the two methods. Initially the only implementation is Signwell, but the system is made pluggable just like e.g. the payment providers, so other suppliers can be added in the future. This should be considered fairly beta at this point, as several parts of it cannot be fully tested until a production account is in place. But the basics are there... --- postgresqleu/digisign/models.py | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 postgresqleu/digisign/models.py (limited to 'postgresqleu/digisign/models.py') diff --git a/postgresqleu/digisign/models.py b/postgresqleu/digisign/models.py new file mode 100644 index 00000000..913f5460 --- /dev/null +++ b/postgresqleu/digisign/models.py @@ -0,0 +1,49 @@ +from django.db import models + + +class DigisignProvider(models.Model): + name = models.CharField(max_length=100, null=False, blank=False, unique=True) + displayname = models.CharField(max_length=100, null=False, blank=False) + classname = models.CharField(max_length=200, null=False, blank=False, verbose_name="Implementation class") + active = models.BooleanField(null=False, blank=False, default=False) + config = models.JSONField(blank=False, null=False, default=dict) + + def __str__(self): + return self.name + + class Meta: + ordering = ('name', ) + + def get_implementation(self): + pieces = self.classname.split('.') + modname = '.'.join(pieces[:-1]) + classname = pieces[-1] + mod = __import__(modname, fromlist=[classname, ]) + return getattr(mod, classname)(self.id, self) + + +class DigisignDocument(models.Model): + provider = models.ForeignKey(DigisignProvider, null=False, blank=False, on_delete=models.CASCADE) + documentid = models.CharField(max_length=100, null=False, blank=True) + handler = models.CharField(max_length=32, null=False, blank=True) + completed = models.BooleanField(null=False, blank=False, default=False) + + class Meta: + unique_together = ( + ('documentid', 'provider'), + ) + + +class DigisignLog(models.Model): + provider = models.ForeignKey(DigisignProvider, null=False, blank=False, on_delete=models.CASCADE) + document = models.ForeignKey(DigisignDocument, null=True, blank=True, on_delete=models.CASCADE) + time = models.DateTimeField(auto_now_add=True, db_index=True) + event = models.CharField(max_length=200, null=False, blank=False) + text = models.CharField(max_length=1000, null=False, blank=False) + fulldata = models.JSONField(null=False, blank=False, default=dict) + + class Meta: + ordering = ('time', ) + indexes = [ + models.Index(fields=('document', '-time')) + ] -- cgit v1.2.3