From 45fe082b94f6979488cb912d6cc903a0bf2c43ac Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 15:51:00 -0500 Subject: [PATCH 1/8] DPK-51: Make initial changes for Django 2 and 3 --- README.md | 4 ++++ django_presskit/models.py | 32 +++++++++++++++++++------------- django_presskit/urls.py | 1 + requirements.txt | 8 +++++--- tests/settings.py | 17 +++++++++++++++++ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c5bc4fa..f9d2b59 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,11 @@ A port of Rami Ismail's [presskit()/dopresskit](https://github.com/ramiismail/do ### Requirements: +<<<<<<< Updated upstream * Django < 2 +======= +* Django>=2.2 +>>>>>>> Stashed changes * django-filer * easy_thumbnails * Markdown diff --git a/django_presskit/models.py b/django_presskit/models.py index d8d621f..275e4e4 100644 --- a/django_presskit/models.py +++ b/django_presskit/models.py @@ -23,7 +23,7 @@ def __str__(self): return self.title + ' ' + self.website class Attachment(models.Model): - content = FilerImageField() + content = FilerImageField(on_delete=models.CASCADE) def __str__(self): return self.content.url @@ -47,7 +47,8 @@ class Company(models.Model): slug = models.SlugField(unique=True) website = models.URLField(null=True, blank=True) header_image = FilerImageField(null=True, blank=True, - related_name='company_header_image') + related_name='company_header_image', + on_delete=models.SET_NULL) based_in = models.CharField(max_length=400, null=True, blank=True) description = models.TextField(null=True, blank=True) history = models.TextField(null=True, blank=True) @@ -113,10 +114,11 @@ class Meta(object): class CompanyVideo(models.Model): name = models.CharField(max_length=400) - company = models.ForeignKey(Company, related_name='videos') + company = models.ForeignKey(Company, related_name='videos', on_delete=models.CASCADE) embed_url = models.URLField(null=True, blank=True) file = FilerFileField(null=True, blank=True, - related_name='company_video') + related_name='company_video', + on_delete=models.SET_NULL) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) @@ -157,7 +159,7 @@ def __str__(self): class Feature(models.Model): description = models.CharField(max_length=1000) - project = models.ForeignKey('Project') + project = models.ForeignKey('Project', on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) @@ -182,7 +184,7 @@ def __str__(self): class Platform(models.Model): name = models.CharField(max_length=200) website = models.URLField(null=True, blank=True) - project = models.ForeignKey('Project') + project = models.ForeignKey('Project', on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) @@ -196,7 +198,7 @@ def __str__(self): class Price(models.Model): price = models.CharField(max_length=200) - project = models.ForeignKey('Project') + project = models.ForeignKey('Project', on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) @@ -212,7 +214,8 @@ class Project(models.Model): title = models.CharField(max_length=200) slug = models.SlugField(unique=True) header_image = FilerImageField(null=True, blank=True, - related_name='project_header_image') + related_name='project_header_image', + on_delete=models.SET_NULL) release_date = models.CharField(max_length=200) website = models.URLField() description = models.TextField() @@ -224,7 +227,8 @@ class Project(models.Model): through='ProjectLogoAttachment', related_name='project_logos') press_can_request_copy = models.BooleanField() - monetization_permission = models.ForeignKey(MonetizationPermission) + monetization_permission = models.ForeignKey(MonetizationPermission, + on_delete=models.CASCADE) distribute_game_id = models.CharField( null=True, blank=True, max_length=25, help_text='The game ID from your Distribute() keyfile (https://dodistribute.com/games/presskit/THIS-ID/)') distribute_access_hash = models.CharField( @@ -237,7 +241,7 @@ class Project(models.Model): awards = models.ManyToManyField('Award', blank=True) credits = models.ManyToManyField(Credit, blank=True) contacts = models.ManyToManyField(Contact, blank=True) - company = models.ForeignKey(Company) + company = models.ForeignKey(Company, on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) asset_archive = FilerFileField(blank=True,null=True) @@ -297,7 +301,7 @@ def __str__(self): class Social(models.Model): name = models.CharField(max_length=200) website = models.URLField() - company = models.ForeignKey(Company) + company = models.ForeignKey(Company, on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) @@ -312,9 +316,11 @@ def __str__(self): class Trailer(models.Model): name = models.CharField(max_length=400) embed_url = models.URLField(null=True, blank=True) - project = models.ForeignKey(Project, related_name='videos') + project = models.ForeignKey(Project, related_name='videos', + on_delete=models.CASCADE) file = FilerFileField(null=True, blank=True, - related_name='trailer_video') + related_name='trailer_video', + on_delete=models.SET_NULL) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) diff --git a/django_presskit/urls.py b/django_presskit/urls.py index 610f7c9..3a5041c 100644 --- a/django_presskit/urls.py +++ b/django_presskit/urls.py @@ -2,6 +2,7 @@ from . import views +app_name = 'presskit' urlpatterns = [ url(r'^$', views.presskit, name='default'), url(r'^(?P[-\w]+)/$', views.presskit, name='company'), diff --git a/requirements.txt b/requirements.txt index a8d02a9..9916bb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ -Django==1.11.29 -django-filer==1.4.0 -easy_thumbnails==2.5 +coverage==4.4.2 +Django==3.1.4 +django-filer==2.0.2 +django-polymorphic==3.0.0 +easy_thumbnails==2.7.1 Markdown==2.6.11 Pillow==6.2.0 future==0.18.2 diff --git a/tests/settings.py b/tests/settings.py index b4b6fee..a90e07c 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -3,11 +3,13 @@ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sites", + "django.contrib.messages", "tests", "django_presskit", "easy_thumbnails", "filer", "adminsortable2", + "django.contrib.admin", ] DATABASES = { @@ -19,12 +21,27 @@ ROOT_URLCONF = "tests.urls" +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.request', + 'django.contrib.messages.context_processors.messages', + ] }, }, ] From 3e7d1e9a952cf94d11e988127df2c8acda6a5e36 Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 15:56:38 -0500 Subject: [PATCH 2/8] DPK-51: Fix additional issues --- django_presskit/models.py | 6 ++++-- requirements.txt | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/django_presskit/models.py b/django_presskit/models.py index 275e4e4..c04c542 100644 --- a/django_presskit/models.py +++ b/django_presskit/models.py @@ -75,7 +75,8 @@ class Company(models.Model): contacts = models.ManyToManyField('Contact', blank=True) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) - asset_archive = FilerFileField(blank=True,null=True) + asset_archive = FilerFileField(blank=True, null=True, + on_delete=models.SET_NULL) def __str__(self): return self.title @@ -244,7 +245,8 @@ class Project(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) - asset_archive = FilerFileField(blank=True,null=True) + asset_archive = FilerFileField(blank=True, null=True, + on_delete=models.SET_NULL) my_order = models.PositiveIntegerField(default=0, blank=False, null=False) class Meta(object): diff --git a/requirements.txt b/requirements.txt index 9916bb1..4dabc01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ coverage==4.4.2 -Django==3.1.4 +django-admin-sortable2==0.7 django-filer==2.0.2 django-polymorphic==3.0.0 +Django==3.1.4 easy_thumbnails==2.7.1 +future==0.18.2 Markdown==2.6.11 Pillow==6.2.0 -future==0.18.2 -django-admin-sortable2==0.7 From 81b8bd47fcbf841124a084257bcbc13a210aa839 Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 16:20:24 -0500 Subject: [PATCH 3/8] DPK-51: Add a matrix of Django and python versions --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63ee15d..954455b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,20 @@ language: python env: PYTHONPATH: . + matrix: + - DJANGO='>=3.1,<3.2' + - DJANGO='>=3.0,<3.1' + - DJANGO='>=2.2,<3.0' + - DJANGO='>=2.1,<2.2' + - DJANGO='>=2.0,<2.1' python: - - "3.6.8" + - 3.8 + - 3.7 + - 3.6 install: - pip install -r requirements.txt - pip install coverage coveralls + - pip install --pre django$DJANGO - pip install . script: - coverage run --source=django_presskit runtests.py From a7d1db60925e3e8ae3e31c2a27954016f6cace4d Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 16:21:31 -0500 Subject: [PATCH 4/8] DPK-51: Fix incomplete merge --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index f9d2b59..7750a79 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,7 @@ A port of Rami Ismail's [presskit()/dopresskit](https://github.com/ramiismail/do ### Requirements: -<<<<<<< Updated upstream -* Django < 2 -======= * Django>=2.2 ->>>>>>> Stashed changes * django-filer * easy_thumbnails * Markdown From 6deae7c912183ea1c91542140ea5c76bf1a2ddee Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 16:24:09 -0500 Subject: [PATCH 5/8] DPK-51: Remove Travis builds below Django 2.2 --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 954455b..599a7eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,6 @@ env: - DJANGO='>=3.1,<3.2' - DJANGO='>=3.0,<3.1' - DJANGO='>=2.2,<3.0' - - DJANGO='>=2.1,<2.2' - - DJANGO='>=2.0,<2.1' python: - 3.8 - 3.7 From 911e654c0777e5b0ddf1f77d3524d75f757c3593 Mon Sep 17 00:00:00 2001 From: Gregory Avery-Weir Date: Sun, 20 Dec 2020 16:44:28 -0500 Subject: [PATCH 6/8] DPK-51: Update version number --- README.md | 4 ++++ setup.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7750a79..554a432 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,10 @@ If you're using nginx and one of your slugs has more than ten underscores, add a ## Changelog +### 1.3.0 + +* Add support for Django 2 and 3, drop support for Django 1 + ### 1.2.0 * Upgrade to support Python 3.6+ diff --git a/setup.py b/setup.py index 6334dc3..9f67b67 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="django_presskit", - version="1.2.0", + version="1.3.0", author="Future Proof Games", author_email="info@futureproofgames.com", description="A port of presskit() to Django", @@ -16,7 +16,7 @@ include_package_data=True, classifiers=[ "Programming Language :: Python :: 3.7", - "Framework :: Django :: 1.11", + "Framework :: Django :: 2.2", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", ], From b34808a3474d2192f1d40adce7f208d845e9e8e4 Mon Sep 17 00:00:00 2001 From: Melissa Avery-Weir Date: Fri, 8 Jan 2021 20:20:37 -0500 Subject: [PATCH 7/8] Update django-admin-sortable2 requirement --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4dabc01..12d320a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ coverage==4.4.2 -django-admin-sortable2==0.7 +django-admin-sortable2==0.7.7 django-filer==2.0.2 django-polymorphic==3.0.0 Django==3.1.4 From aeaf6e4cfd3e67c990ac06a978ea82f266edbb8f Mon Sep 17 00:00:00 2001 From: Melissa Avery-Weir Date: Fri, 8 Jan 2021 21:06:17 -0500 Subject: [PATCH 8/8] Bump Pillow version for security --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 12d320a..1db1a0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ Django==3.1.4 easy_thumbnails==2.7.1 future==0.18.2 Markdown==2.6.11 -Pillow==6.2.0 +Pillow==7.1.0