diff --git a/REQUIREMENTS.txt b/REQUIREMENTS.txt index be336b7e..2e741ec8 100644 --- a/REQUIREMENTS.txt +++ b/REQUIREMENTS.txt @@ -61,3 +61,4 @@ pyjwt==1.7.1 djangorestframework-simplejwt==4.4 django-rest-auth==0.9.5 drf-yasg +django-matomo==0.1.6 \ No newline at end of file diff --git a/dockerize/docker/REQUIREMENTS.txt b/dockerize/docker/REQUIREMENTS.txt index 1ee60259..4de38450 100644 --- a/dockerize/docker/REQUIREMENTS.txt +++ b/dockerize/docker/REQUIREMENTS.txt @@ -56,3 +56,4 @@ django-rest-multiple-models==2.1.3 django-preferences==1.0.0 PyWavefront==1.3.3 +django-matomo==0.1.6 diff --git a/qgis-app/plugins/forms.py b/qgis-app/plugins/forms.py index 44e0d7be..40c8ab5a 100644 --- a/qgis-app/plugins/forms.py +++ b/qgis-app/plugins/forms.py @@ -43,10 +43,25 @@ class Meta: "tracker", "repository", "owners", + "maintainer", + "display_created_by", "tags", "server", ) + def __init__(self, *args, **kwargs): + super(PluginForm, self).__init__(*args, **kwargs) + self.fields['owners'].label = "Collaborators" + + choices = ( + (self.instance.created_by.pk, self.instance.created_by.username + " (Plugin creator)"), + ) + for owner in self.instance.owners.exclude(pk=self.instance.created_by.pk): + choices += ((owner.pk, owner.username + " (Collaborator)"),) + + self.fields['maintainer'].choices = choices + self.fields['maintainer'].label = "Maintainer" + def clean(self): """ Check author diff --git a/qgis-app/plugins/migrations/0005_plugin_maintainer.py b/qgis-app/plugins/migrations/0005_plugin_maintainer.py new file mode 100644 index 00000000..dfeffa0b --- /dev/null +++ b/qgis-app/plugins/migrations/0005_plugin_maintainer.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.25 on 2023-11-29 22:45 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + +def populate_maintainer(apps, schema_editor): + Plugin = apps.get_model('plugins', 'Plugin') + + # Set the maintainer as the plugin creator by default + for obj in Plugin.objects.all(): + obj.maintainer = obj.created_by + obj.save() + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('plugins', '0004_merge_20231122_0223'), + ] + + operations = [ + migrations.AddField( + model_name='plugin', + name='maintainer', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='plugins_maintainer', to=settings.AUTH_USER_MODEL, verbose_name='Maintainer'), + ), + migrations.RunPython(populate_maintainer), + ] diff --git a/qgis-app/plugins/migrations/0006_plugin_display_created_by.py b/qgis-app/plugins/migrations/0006_plugin_display_created_by.py new file mode 100644 index 00000000..85af8484 --- /dev/null +++ b/qgis-app/plugins/migrations/0006_plugin_display_created_by.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.25 on 2023-11-29 23:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('plugins', '0005_plugin_maintainer'), + ] + + operations = [ + migrations.AddField( + model_name='plugin', + name='display_created_by', + field=models.BooleanField(default=False, verbose_name='Display "Created by" in plugin details'), + ), + ] diff --git a/qgis-app/plugins/models.py b/qgis-app/plugins/models.py index 495821c8..9f9cc209 100644 --- a/qgis-app/plugins/models.py +++ b/qgis-app/plugins/models.py @@ -323,6 +323,22 @@ class Plugin(models.Model): related_name="plugins_created_by", on_delete=models.CASCADE, ) + + # maintainer + maintainer = models.ForeignKey( + User, + verbose_name=_("Maintainer"), + related_name="plugins_maintainer", + on_delete=models.CASCADE, + blank=True, + null=True + ) + + display_created_by = models.BooleanField( + _('Display "Created by" in plugin details'), + default=False + ) + author = models.CharField( _("Author"), help_text=_( @@ -530,6 +546,7 @@ def save(self, keep_date=False, *args, **kwargs): """ Soft triggers: * updates modified_on if keep_date is not set + * set maintainer to the plugin creator when not specified """ if self.pk and not keep_date: import logging @@ -538,6 +555,8 @@ def save(self, keep_date=False, *args, **kwargs): self.modified_on = datetime.datetime.now() if not self.pk: self.modified_on = datetime.datetime.now() + if not self.maintainer: + self.maintainer = self.created_by super(Plugin, self).save(*args, **kwargs) diff --git a/qgis-app/plugins/templates/plugins/plugin_detail.html b/qgis-app/plugins/templates/plugins/plugin_detail.html index 2c2f6869..1b2598c3 100644 --- a/qgis-app/plugins/templates/plugins/plugin_detail.html +++ b/qgis-app/plugins/templates/plugins/plugin_detail.html @@ -164,9 +164,16 @@