[extensions-web/wip/api/v1] extensions: added license field to extension version model
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/wip/api/v1] extensions: added license field to extension version model
- Date: Mon, 12 Sep 2022 16:46:28 +0000 (UTC)
commit f681af8adb544643a774facbacb9e84aaa263865
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Mon Sep 12 20:42:02 2022 +0400
extensions: added license field to extension version model
Fixes: https://gitlab.gnome.org/Infrastructure/extensions-web/-/issues/53
.../migrations/0016_extensionversion_license.py | 18 ++++++++++++++++++
sweettooth/extensions/models.py | 19 +++++++++++++++++++
sweettooth/extensions/serializers.py | 1 +
sweettooth/extensions/tests.py | 1 +
4 files changed, 39 insertions(+)
---
diff --git a/sweettooth/extensions/migrations/0016_extensionversion_license.py
b/sweettooth/extensions/migrations/0016_extensionversion_license.py
new file mode 100644
index 0000000..968b5da
--- /dev/null
+++ b/sweettooth/extensions/migrations/0016_extensionversion_license.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.15 on 2022-09-12 16:12
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('extensions', '0015_extension_rating'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='extensionversion',
+ name='license',
+ field=models.CharField(choices=[('Apache-2.0', 'Apache 2.0'), ('BSD-2-Clause', '2-Clause BSD'),
('BSD-3-Clause', '3-Clause BSD'), ('EPL-2.0', 'EPL 2.0'), ('GPL-2.0', 'GPL 2.0'), ('GPL-2.0 or later',
'Gpl20Orlater'), ('GPL-3.0', 'GPL 2.0 or later'), ('GPL-3.0-or-later', 'GPL 3.0 or later'), ('MIT', 'MIT'),
('MPL-2.0', 'MPL 2.0')], default='GPL-2.0', max_length=24),
+ ),
+ ]
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index fdc54df..4ebefb9 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -374,6 +374,19 @@ def make_filename(obj, filename=None):
return "%s.v%d.shell-extension.zip" % (obj.extension.uuid, obj.version)
+class Licenses(models.TextChoices):
+ Apache20 = 'Apache-2.0', 'Apache 2.0'
+ BSD2Clause = 'BSD-2-Clause', '2-Clause BSD'
+ BSD3Clause = 'BSD-3-Clause', '3-Clause BSD'
+ EPL20 = 'EPL-2.0', 'EPL 2.0'
+ GPL20 = 'GPL-2.0', 'GPL 2.0'
+ GPL20OrLater = 'GPL-2.0 or later',
+ GPL30 = 'GPL-3.0', 'GPL 2.0 or later'
+ GPL30OrLater = 'GPL-3.0-or-later', 'GPL 3.0 or later',
+ MIT = 'MIT', 'MIT'
+ MPL20 = 'MPL-2.0', 'MPL 2.0'
+
+
class ExtensionVersion(models.Model):
extension: Extension = models.ForeignKey(Extension, on_delete=models.CASCADE, related_name="versions")
version: int = models.IntegerField(default=0)
@@ -382,6 +395,11 @@ class ExtensionVersion(models.Model):
shell_versions = models.ManyToManyField(ShellVersion)
session_modes = models.ManyToManyField(SessionMode)
created = models.DateTimeField(auto_now_add=True, null=True)
+ license = models.CharField(
+ choices=Licenses.choices,
+ default=Licenses.GPL20,
+ max_length=24
+ )
class Meta:
unique_together = ('extension', 'version'),
@@ -509,6 +527,7 @@ class ExtensionVersion(models.Model):
def is_inactive(self):
return self.status == STATUS_INACTIVE
+
# providing_args=["request", "version"]
submitted_for_review = Signal()
# providing_args=["request", "version", "review"]
diff --git a/sweettooth/extensions/serializers.py b/sweettooth/extensions/serializers.py
index dd1d0b4..7bcbc42 100644
--- a/sweettooth/extensions/serializers.py
+++ b/sweettooth/extensions/serializers.py
@@ -86,6 +86,7 @@ class ExtensionUploadSerializer(serializers.Serializer):
source = serializers.FileField(required=True)
shell_license_compliant = serializers.BooleanField(required=True)
tos_compliant = serializers.BooleanField(required=True)
+ license = serializers.ChoiceField(choices=models.Licenses.values)
def validate_source(self, value):
try:
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 98177f3..5654dc4 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -235,6 +235,7 @@ class UploadTest(BasicUserTestCase, TransactionTestCase):
'source': f,
'shell_license_compliant': True,
'tos_compliant': True,
+ 'license': models.Licenses.GPL20.value,
},
follow=True,
format='multipart'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]