[extensions-web/wip/api/v1] Merge branch 'master' into wip/api/v1




commit b9393dfb35dc7835e7e101392ed0fbbc8feba9a3
Merge: 5e04c9c bebabd5
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Sat Aug 13 13:50:56 2022 +0400

    Merge branch 'master' into wip/api/v1

 po/LINGUAS                                         |   1 +
 po/extensions-web.pot                              |  66 +++-
 po/ka.po                                           | 409 +++++++++++++++++++++
 po/ru.po                                           |  18 +-
 requirements.in                                    |   2 +-
 requirements.txt                                   |   6 +-
 .../migrations/0011_extension_allow_comments.py    |  18 +
 ...20200511_1019.py => 0012_auto_20200511_1019.py} |   2 +-
 ...20200523_1243.py => 0013_auto_20200523_1243.py} |   2 +-
 ...ecommended.py => 0014_extension_recommended.py} |   2 +-
 ...xtension_rating.py => 0015_extension_rating.py} |   2 +-
 sweettooth/extensions/models.py                    |   5 +-
 .../extensions/templates/extensions/detail.html    |   5 +
 .../templates/extensions/detail_edit.html          |   5 +-
 .../extensions/templates/extensions/local.html     |   4 +-
 sweettooth/extensions/tests.py                     |  24 +-
 sweettooth/extensions/views.py                     |  11 +-
 sweettooth/ratings/__init__.py                     |  11 +
 sweettooth/ratings/moderation.py                   |   6 +
 sweettooth/ratings/views.py                        |   5 +
 sweettooth/static/css/sweettooth.css               |  12 +-
 sweettooth/static/js/browser_extension.js          |  13 +-
 sweettooth/static/js/extensions.js                 |  12 +
 sweettooth/static/js/settings.js                   |   2 +-
 sweettooth/static/js/versions/5/main.js            |   2 +
 sweettooth/static/js/versions/6/main.js            |   2 +
 26 files changed, 578 insertions(+), 69 deletions(-)
---
diff --cc requirements.in
index d47c8b2,54e1669..79b3965
--- a/requirements.in
+++ b/requirements.in
@@@ -1,9 -1,6 +1,9 @@@
- Django==3.2.13
+ Django==3.2.15
 +djangorestframework==3.13.1
  django-autoslug==1.9.8
  django-contrib-comments==2.1.0
 +django-elasticsearch-dsl==7.2.2
 +django-filter==21.1
  django-registration==3.2
  Pygments==2.11.2
  Pillow==9.0.1
diff --cc sweettooth/extensions/migrations/0012_auto_20200511_1019.py
index 4796817,0000000..33554ea
mode 100644,000000..100644
--- a/sweettooth/extensions/migrations/0012_auto_20200511_1019.py
+++ b/sweettooth/extensions/migrations/0012_auto_20200511_1019.py
@@@ -1,20 -1,0 +1,20 @@@
 +# Generated by Django 2.2.12 on 2020-05-11 10:19
 +
 +from django.conf import settings
 +from django.db import migrations, models
 +import django.db.models.deletion
 +
 +
 +class Migration(migrations.Migration):
 +
 +    dependencies = [
-         ('extensions', '0010_session_modes'),
++        ('extensions', '0011_extension_allow_comments'),
 +    ]
 +
 +    operations = [
 +        migrations.AlterField(
 +            model_name='extension',
 +            name='creator',
 +            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='extensions', 
to=settings.AUTH_USER_MODEL),
 +        ),
 +    ]
diff --cc sweettooth/extensions/migrations/0013_auto_20200523_1243.py
index 4e4974b,0000000..25a3d5a
mode 100644,000000..100644
--- a/sweettooth/extensions/migrations/0013_auto_20200523_1243.py
+++ b/sweettooth/extensions/migrations/0013_auto_20200523_1243.py
@@@ -1,52 -1,0 +1,52 @@@
 +# Generated by Django 2.2.12 on 2020-05-23 12:43
 +
 +import os
 +
 +from datetime import datetime
 +
 +from django.db import migrations, models
 +
 +def populate_data(apps, schema_editor):
 +    Extension = apps.get_model("extensions", "Extension")
 +    ExtensionVersion = apps.get_model("extensions", "ExtensionVersion")
 +
 +    Extension.objects.all().update(updated=models.F('created'))
 +
 +    for version in ExtensionVersion.objects.all():
 +        # We don't have better choise than mtime now
 +        try:
 +            version.created = datetime.fromtimestamp(
 +                os.path.getmtime(
 +                    version.source.storage.path(version.source.name)
 +                )
 +            )
 +            version.save()
 +        except FileNotFoundError:
 +            pass
 +
 +        if version.created and version.extension.updated < version.created:
 +            version.extension.updated = version.created
 +            version.extension.save()
 +
 +def revert_data(apps, schema_editor):
 +    pass
 +
 +class Migration(migrations.Migration):
 +
 +    dependencies = [
-         ('extensions', '0011_auto_20200511_1019'),
++        ('extensions', '0012_auto_20200511_1019'),
 +    ]
 +
 +    operations = [
 +        migrations.AddField(
 +            model_name='extension',
 +            name='updated',
 +            field=models.DateTimeField(default=None, null=True),
 +        ),
 +        migrations.AddField(
 +            model_name='extensionversion',
 +            name='created',
 +            field=models.DateTimeField(auto_now_add=True, null=True),
 +        ),
 +        migrations.RunPython(populate_data, revert_data),
 +    ]
diff --cc sweettooth/extensions/migrations/0014_extension_recommended.py
index 5c70c6b,0000000..04fbd62
mode 100644,000000..100644
--- a/sweettooth/extensions/migrations/0014_extension_recommended.py
+++ b/sweettooth/extensions/migrations/0014_extension_recommended.py
@@@ -1,18 -1,0 +1,18 @@@
 +# Generated by Django 2.2.12 on 2020-05-26 21:26
 +
 +from django.db import migrations, models
 +
 +
 +class Migration(migrations.Migration):
 +
 +    dependencies = [
-         ('extensions', '0012_auto_20200523_1243'),
++        ('extensions', '0013_auto_20200523_1243'),
 +    ]
 +
 +    operations = [
 +        migrations.AddField(
 +            model_name='extension',
 +            name='recommended',
 +            field=models.BooleanField(default=False),
 +        ),
 +    ]
diff --cc sweettooth/extensions/migrations/0015_extension_rating.py
index 3ccf1d6,0000000..706f0ce
mode 100644,000000..100644
--- a/sweettooth/extensions/migrations/0015_extension_rating.py
+++ b/sweettooth/extensions/migrations/0015_extension_rating.py
@@@ -1,60 -1,0 +1,60 @@@
 +"""
 +    GNOME Shell extensions repository
 +    Copyright (C) 2021  Yuri Konotopov <ykonotopov gnome org>
 +
 +    This program is free software: you can redistribute it and/or modify
 +    it under the terms of the GNU Affero General Public License as published by
 +    the Free Software Foundation, either version 3 of the License, or
 +    (at your option) any later version.
 +"""
 +
 +from django.db import migrations, models
 +
 +
 +def populate_data(apps, schema_editor):
 +    Extension = apps.get_model("extensions", "Extension")
 +    RatingComment = apps.get_model("ratings", "RatingComment")
 +    comments = (RatingComment.objects
 +                             .filter(rating__gt=0)
 +                             .values('object_pk')
 +                             .annotate(
 +                                rating_sum=models.Sum('rating'),
 +                                rated=models.Count('object_pk'))
 +                             .order_by('object_pk'))  # https://code.djangoproject.com/ticket/32546
 +
 +    for comment in comments:
 +        if comment.get('rated') and comment.get('rating_sum'):
 +            try:
 +                extension = Extension.objects.get(pk=comment.get('object_pk'))
 +            except Extension.DoesNotExist:
 +                continue
 +
 +            extension.rated = comment.get('rated')
 +            extension.rating = comment.get('rating_sum') / extension.rated
 +
 +        extension.save()
 +
 +
 +def revert_data(apps, schema_editor):
 +    pass
 +
 +
 +class Migration(migrations.Migration):
 +    dependencies = [
-         ('extensions', '0013_extension_recommended'),
++        ('extensions', '0014_extension_recommended'),
 +        ('ratings', '0001_initial'),
 +    ]
 +
 +    operations = [
 +        migrations.AddField(
 +            model_name='extension',
 +            name='rated',
 +            field=models.IntegerField(default=0),
 +        ),
 +        migrations.AddField(
 +            model_name='extension',
 +            name='rating',
 +            field=models.FloatField(default=0),
 +        ),
 +        migrations.RunPython(populate_data, revert_data),
 +    ]
diff --cc sweettooth/extensions/models.py
index 0db1345,760eb1f..fa3e5bb
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@@ -127,12 -126,9 +127,13 @@@ class Extension(models.Model)
      description = models.TextField(blank=True)
      url = HttpURLField(blank=True)
      created = models.DateTimeField(auto_now_add=True)
 +    updated = models.DateTimeField(default=None, null=True)
      downloads = models.PositiveIntegerField(default=0)
      popularity = models.IntegerField(default=0)
 +    recommended = models.BooleanField(default=False)
 +    rating = models.FloatField(default=0)
 +    rated = models.IntegerField(default=0)
+     allow_comments = models.BooleanField(default=True)
  
      class Meta:
          permissions = (


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]