From dfae2ed0d2952c3803153e0d3d6c01679964a366 Mon Sep 17 00:00:00 2001 From: Sindre Lothe <31065755+sindrelothe@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:12:51 +0200 Subject: [PATCH 01/41] Create django.yml --- .github/workflows/django.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/django.yml diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml new file mode 100644 index 0000000..863be9a --- /dev/null +++ b/.github/workflows/django.yml @@ -0,0 +1,50 @@ +name: Django CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +# Prevent multiple workflows with same branch/pull_request +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +env: + PIPENV_VENV_IN_PROJECT: 1 + ENV: development + SECRET_KEY: NOT SET + DJANGO_SUPERUSER_USERNAME: admin + DJANGO_SUPERUSER_PASSWORD: Django123 + DJANGO_SUPERUSER_EMAIL: admin@example.com + +jobs: + + job_build_django: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.7.5' # Closest version to 3.7.3 available. + + - name: Install dependencies + run: | + python -V + PY=$(which python) + echo $PY + python -m pip install --upgrade pip + python -m pip install pipenv + python -m pipenv install --python $PY + + - name: Run pylint + run: python -m pipenv run pylint accounts nbb plakat rekenett root + + - name: Verify migrations + run: | + python -m pipenv run python manage.py migrate + - name: Run tests + run: python -m pipenv run pytest From 220f4107c3f9db287a795063e8e2730fb0718e40 Mon Sep 17 00:00:00 2001 From: Sindre Lothe <31065755+sindrelothe@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:32:00 +0200 Subject: [PATCH 02/41] Change files to correct project in pylint command --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 863be9a..543eee3 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -41,7 +41,7 @@ jobs: python -m pipenv install --python $PY - name: Run pylint - run: python -m pipenv run pylint accounts nbb plakat rekenett root + run: python -m pipenv run pylint infoscreen root - name: Verify migrations run: | From 1fa624813fb58a04e21b4beb8ff925bbf97023f1 Mon Sep 17 00:00:00 2001 From: Sindre Lothe <31065755+sindrelothe@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:49:01 +0200 Subject: [PATCH 03/41] change branch name to "main" --- .github/workflows/django.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 543eee3..2fd9a9d 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -2,9 +2,9 @@ name: Django CI on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] # Prevent multiple workflows with same branch/pull_request concurrency: From 2b339e48f0b1fbb3ea9dca5f934869bd8d1b393f Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Thu, 21 Apr 2022 19:51:39 +0200 Subject: [PATCH 04/41] fix linting errors for some files --- infoscreen/admin.py | 9 ++--- infoscreen/apps.py | 8 ++-- infoscreen/models/color.py | 22 +++++------ infoscreen/models/image.py | 5 ++- infoscreen/models/screen.py | 8 ++-- infoscreen/models/tag.py | 25 ++++++------ infoscreen/models/video.py | 8 ++-- infoscreen/templatetags/infoscreen_tags.py | 1 - infoscreen/urls.py | 3 +- infoscreen/utils/__init__.py | 21 +++++----- root/constants.py | 3 +- root/models/__init__.py | 2 +- root/models/base.py | 45 +++++++++++----------- root/settings/base.py | 2 +- root/settings/heroku.py | 13 ++++--- root/urls.py | 10 +---- 16 files changed, 89 insertions(+), 96 deletions(-) diff --git a/infoscreen/admin.py b/infoscreen/admin.py index 59d9934..a97bae8 100644 --- a/infoscreen/admin.py +++ b/infoscreen/admin.py @@ -8,10 +8,10 @@ class ScreenAdmin(root_models.CustomBaseAdmin): list_display = ['name'] ordering = [] list_filter = ['images', 'videos'] - filter_horizontal = ['images','videos'] + filter_horizontal = ['images', 'videos'] search_fields = ['name', 'slug'] - - + + class ScreenHasImageAdmin(admin.ModelAdmin): list_display = ['screen', 'image', 'nr'] ordering = ['screen', 'nr'] @@ -36,8 +36,7 @@ class VideoAdmin(root_models.CustomBaseAdmin): search_fields = ['name'] - admin.site.register(infoscreen_models.Screen, ScreenAdmin) # admin.site.register(infoscreen_models.ScreenHasImage, ScreenHasImageAdmin) admin.site.register(infoscreen_models.Image, ImageAdmin) -admin.site.register(infoscreen_models.Video, VideoAdmin) \ No newline at end of file +admin.site.register(infoscreen_models.Video, VideoAdmin) diff --git a/infoscreen/apps.py b/infoscreen/apps.py index 7de3fea..c7b5062 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -4,13 +4,13 @@ class InfoScreenConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'infoscreen' - + def ready(self): - + from django.core import management - + try: # https://docs.djangoproject.com/en/3.0/ref/django-admin/#createsuperuser management.call_command('createsuperuser', interactive=False) except: - pass \ No newline at end of file + pass diff --git a/infoscreen/models/color.py b/infoscreen/models/color.py index 69f246a..a60fe09 100644 --- a/infoscreen/models/color.py +++ b/infoscreen/models/color.py @@ -1,31 +1,32 @@ +import re +from django.core.exceptions import ValidationError from django.db import models - from root import models as root_models class Color(root_models.CustomBaseModel): name = models.CharField(max_length=200, null=True, blank=True, verbose_name='navn') - hex = models.CharField(max_length=6, null=True, blank=True, verbose_name="hex", help_text="Fargekode i hex (6 symboler)") + hex = models.CharField(max_length=6, null=True, blank=True, verbose_name='hex', help_text='Fargekode i hex (6 symboler)') class Meta: ordering = [] verbose_name = 'farge' verbose_name_plural = 'farger' - + def __str__(self): - return f"{self.get_name()}" - + return f'{self.get_name()}' + def get_name(self): if self.name: return self.name return self.hex - + def as_css(self): # TODO: handle COLOR_RANDOM # if self.name == root_constants.COLOR_RANDOM: - # return - return f"#{self.hex}" - + # return + return f'#{self.hex}' + def clean(self, *args, **kwargs): super().clean(*args, **kwargs) errors = {} @@ -34,8 +35,7 @@ def clean(self, *args, **kwargs): errors['hex'] = 'Ugyldig format. Bruk 0-9 og A-F' if errors: raise ValidationError(errors) - + def save(self, *args, **kwargs): self.clean() super().save(*args, **kwargs) - diff --git a/infoscreen/models/image.py b/infoscreen/models/image.py index 81a4e81..e74aa86 100644 --- a/infoscreen/models/image.py +++ b/infoscreen/models/image.py @@ -2,9 +2,10 @@ from root import models as root_models + class Image(root_models.CustomBaseModel): name = models.CharField(max_length=140, null=True, blank=True) url = models.URLField(null=False, blank=False) - + def __str__(self): - return f"{self.name}" \ No newline at end of file + return f'{self.name}' diff --git a/infoscreen/models/screen.py b/infoscreen/models/screen.py index dcb4576..230a803 100644 --- a/infoscreen/models/screen.py +++ b/infoscreen/models/screen.py @@ -5,19 +5,19 @@ class Screen(root_models.CustomBaseModel): name = models.CharField(max_length=140, unique=True, null=True, blank=True) slug = models.CharField(max_length=140, unique=True, null=False, blank=False) - + # images = models.ManyToManyField('Image', through='ScreenHasImage') images = models.ManyToManyField('infoscreen.Image', blank=True) videos = models.ManyToManyField('infoscreen.Video', blank=True) def __str__(self): - return f"{self.name}" - + return f'{self.name}' + # class ScreenHasImage(models.Model): # screen = models.ForeignKey('infoscreen.Screen', on_delete=models.CASCADE, null=False, blank=False) # image = models.ForeignKey('infoscreen.Image', on_delete=models.CASCADE, null=False, blank=False) # nr = models.IntegerField(null=False, blank=False) -# +# # class Meta: # unique_together = ['screen', 'image'] diff --git a/infoscreen/models/tag.py b/infoscreen/models/tag.py index b863c50..2c21a16 100644 --- a/infoscreen/models/tag.py +++ b/infoscreen/models/tag.py @@ -9,27 +9,28 @@ # End: imports ----------------------------------------------------------------- - + class Tag(root_models.CustomBaseModel): - name = models.CharField(max_length=200, unique=True, null=False, blank=False, verbose_name='navn', help_text="En vilkårlig egenskap til en plante. (Tips: Du kan prefikse tags med kolon ':', f.eks. 'familie:fiola' )") + name = models.CharField( + max_length=200, unique=True, null=False, blank=False, verbose_name='navn', help_text='En vilkårlig egenskap til en plante. (Tips: Du kan prefikse tags med kolon ":", f.eks. "familie:fiola" )' + ) bg = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_bg', verbose_name='bakgrunnsfarge') font = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_font', verbose_name='skriftfarge') group = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, related_name='children', verbose_name='gruppe') - + class Meta: ordering = [] verbose_name = 'tag' verbose_name_plural = 'tags' - + def __str__(self): - return f"{self.full_name()}" - + return f'{self.full_name()}' + def full_name(self): if self.group: - return f"{self.group.full_name()} :: {self.name}" - return f"{self.name}" - - + return f'{self.group.full_name()} :: {self.name}' + return f'{self.name}' + def color_list(self): """Hierarchical list of colors from least to most significant""" colors = [] @@ -38,8 +39,6 @@ def color_list(self): if self.color: colors.append(self.color) return colors - + def color_list_css(self): return [color.as_css() for color in self.color_list()] - - \ No newline at end of file diff --git a/infoscreen/models/video.py b/infoscreen/models/video.py index 091d489..bfc8e8c 100644 --- a/infoscreen/models/video.py +++ b/infoscreen/models/video.py @@ -1,15 +1,15 @@ from django.db import models +from root import models as root_models from ..utils.__init__ import parse_url -from root import models as root_models class Video(root_models.CustomBaseModel): name = models.CharField(max_length=140, null=True, blank=True) youtube_code = models.CharField(max_length=140, null=False, blank=False) - + def __str__(self): - return f"{self.name}" - + return f'{self.name}' + def save(self, *args, **kwargs): self.youtube_code = parse_url(self.youtube_code) super().save(*args, **kwargs) diff --git a/infoscreen/templatetags/infoscreen_tags.py b/infoscreen/templatetags/infoscreen_tags.py index 371ca4f..48de874 100644 --- a/infoscreen/templatetags/infoscreen_tags.py +++ b/infoscreen/templatetags/infoscreen_tags.py @@ -1,6 +1,5 @@ # imports from django import template -from django.conf import settings # End: imports ----------------------------------------------------------------- register = template.Library() diff --git a/infoscreen/urls.py b/infoscreen/urls.py index f9aa326..c3f38ce 100644 --- a/infoscreen/urls.py +++ b/infoscreen/urls.py @@ -1,4 +1,4 @@ -from django.urls import path, include +from django.urls import path from django.views.generic.base import RedirectView from infoscreen import views @@ -10,4 +10,3 @@ path('screen//', views.ScreenView.as_view(), name='view_screen'), path('screens/', views.ScreenListView.as_view(), name='screen_list'), ] - diff --git a/infoscreen/utils/__init__.py b/infoscreen/utils/__init__.py index 2fbc278..acc94a2 100644 --- a/infoscreen/utils/__init__.py +++ b/infoscreen/utils/__init__.py @@ -1,16 +1,15 @@ -TEST1 = "https://youtu.be/16GVZ6s5XEw" -TEST2 = "https://www.youtube.com/watch?v=16GVZ6s5XEw&ab_channel=BigLozOfficial" -TEST3 = "https://youtu.be/16GVZ6s5XEw/?id=1" +TEST1 = 'https://youtu.be/16GVZ6s5XEw' +TEST2 = 'https://www.youtube.com/watch?v=16GVZ6s5XEw&ab_channel=BigLozOfficial' +TEST3 = 'https://youtu.be/16GVZ6s5XEw/?id=1' def parse_url(url): - if "https://youtu.be/" in url: - new = url.replace("https://youtu.be/", '') - new = new.split("/", 1) + if 'https://youtu.be/' in url: + new = url.replace('https://youtu.be/', '') + new = new.split('/', 1) return new[0] - elif "https://www.youtube.com/" in url: - new = url.split("=", 1) - new = new[1].split("&", 1) + if 'https://www.youtube.com/' in url: + new = url.split('=', 1) + new = new[1].split('&', 1) return new[0] - else: - return "oopsie woopsie, you made a fucky wucky" + return 'oopsie woopsie, you made a fucky wucky' diff --git a/root/constants.py b/root/constants.py index d172e39..2e1e696 100644 --- a/root/constants.py +++ b/root/constants.py @@ -1,4 +1,3 @@ - class Environment: """ Useful in eg. templates @@ -8,6 +7,6 @@ class Environment: DEV = 'development' HEROKU = 'heroku' PROD = 'production' - + ALL = [BASE, DEV, PROD, HEROKU] VALID = [DEV, PROD, HEROKU] diff --git a/root/models/__init__.py b/root/models/__init__.py index 8922107..3ebe28d 100644 --- a/root/models/__init__.py +++ b/root/models/__init__.py @@ -1 +1 @@ -from .base import CustomBaseAdmin, CustomBaseModel, CustomModelForm \ No newline at end of file +from .base import CustomBaseAdmin, CustomBaseModel, CustomModelForm diff --git a/root/models/base.py b/root/models/base.py index f0ba849..aa09698 100644 --- a/root/models/base.py +++ b/root/models/base.py @@ -1,5 +1,4 @@ # imports -from datetime import time, date, datetime, timedelta from django import forms from django.db import models @@ -7,14 +6,14 @@ from django.utils import timezone from django.contrib import admin from django.contrib.auth import models as auth_models -from django.utils.translation import ugettext_lazy as _ -from django.template.defaultfilters import filesizeformat + # End: imports ----------------------------------------------------------------- # https://github.com/django/django/blob/master/django/forms/models.py class CustomModelForm(forms.ModelForm): + # pylint: disable=keyword-arg-before-vararg def save(self, commit=True, *args, **kwargs): """ Override django ModelForm.save() to implement kwargs. Do not use super() in this class! @@ -25,16 +24,18 @@ def save(self, commit=True, *args, **kwargs): a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance. """ + # pylint: disable=invalid-string-quote + # pylint: disable=W0212 + # pylint: disable=C0209 + # pylint: disable=W0201 if self.errors: - raise ValueError( - "The %s could not be %s because the data didn't validate." % ( - self.instance._meta.object_name, - 'created' if self.instance._state.adding else 'changed', - ) - ) + raise ValueError('The %s could not be %s because the data didn\'t validate.' % ( + self.instance._meta.object_name, + 'created' if self.instance._state.adding else 'changed', + )) if commit: # If committing, save the instance and the m2m data immediately. - self.instance.save(*args, **kwargs) # <--- This is the only difference + self.instance.save(*args, **kwargs) # <--- This is the only difference self._save_m2m() else: # If not committing, add a method to the form to allow deferred @@ -45,6 +46,7 @@ def save(self, commit=True, *args, **kwargs): class CustomBaseAdmin(admin.ModelAdmin): readonly_fields = ['creator', 'created', 'last_edited', 'last_editor'] + # list_display = [] # ordering = [] # list_filter = [] @@ -52,38 +54,39 @@ class CustomBaseAdmin(admin.ModelAdmin): # search_fields = [] def save_model(self, request, obj, form, change): + # pylint: disable=W0703 try: if not change: obj.creator = request.user obj.created = timezone.now() obj.last_editor = request.user obj.last_edited = timezone.now() - except Exception as e: + except Exception: pass return super().save_model(request, obj, form, change) class CustomBaseModel(models.Model): - last_editor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, editable=False, related_name="editor_%(class)s_set", verbose_name="Sist redigert av") - last_edited = models.DateTimeField(null=True, blank=True, editable=False, verbose_name="Sist redigert") - creator = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, editable=False, related_name="creator_%(class)s_set", verbose_name="Opprettet av") - created = models.DateTimeField(null=True, blank=True, editable=False, verbose_name="Opprettet") + last_editor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, editable=False, related_name='editor_%(class)s_set', verbose_name='Sist redigert av') + last_edited = models.DateTimeField(null=True, blank=True, editable=False, verbose_name='Sist redigert') + creator = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, editable=False, related_name='creator_%(class)s_set', verbose_name='Opprettet av') + created = models.DateTimeField(null=True, blank=True, editable=False, verbose_name='Opprettet') class Meta: abstract = True def is_edited(self): - return (self.created != self.last_edited) - + return self.created != self.last_edited + def clean(self, *args, **kwargs): pass def save(self, *args, **kwargs): self.clean() - user = kwargs.pop('user', None) # Must pop because super().save() doesn't accept user - if isinstance(user, auth_models.AnonymousUser): - user = None # creator and last_editor can't be AnonymousUser + user = kwargs.pop('user', None) # Must pop because super().save() doesn't accept user + if isinstance(user, auth_models.AnonymousUser): + user = None # creator and last_editor can't be AnonymousUser if not self.id: self.created = timezone.now() if user: @@ -93,5 +96,3 @@ def save(self, *args, **kwargs): self.last_editor = user super().save(*args, **kwargs) - - diff --git a/root/settings/base.py b/root/settings/base.py index 7fd03cc..fab0b3f 100644 --- a/root/settings/base.py +++ b/root/settings/base.py @@ -141,7 +141,7 @@ ################## LOGGING ################## -LOGFILENAME = f"{BASE_DIR}/info_screens.log" +LOGFILENAME = f'{BASE_DIR}/info_screens.log' LOGGING = { 'version': 1, diff --git a/root/settings/heroku.py b/root/settings/heroku.py index 34f4ac6..f9eef0c 100644 --- a/root/settings/heroku.py +++ b/root/settings/heroku.py @@ -1,14 +1,17 @@ -from .base import * +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import import os +from ast import literal_eval import django_heroku - +from .base import * ALLOWED_HOSTS = ['info-screens.herokuapp.com'] # Values are set in heroku dashboard SECRET_KEY = os.environ['SECRET_KEY'] -DEBUG = eval(os.environ['DEBUG']) +DEBUG = literal_eval(os.environ['DEBUG']) +# pylint: disable=undefined-variable # Ensure correct ENV ENV = Environment.HEROKU @@ -16,8 +19,8 @@ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' MIDDLEWARE += [ - 'whitenoise.middleware.WhiteNoiseMiddleware', # whitenoise, heroku + 'whitenoise.middleware.WhiteNoiseMiddleware', # whitenoise, heroku ] # activate django-heroku. -django_heroku.settings(locals()) \ No newline at end of file +django_heroku.settings(locals()) diff --git a/root/urls.py b/root/urls.py index d84c9d7..c3f63fc 100644 --- a/root/urls.py +++ b/root/urls.py @@ -20,17 +20,11 @@ from django.contrib import admin from django.conf.urls.static import static -from infoscreen import views as infoscreen_views - -urlpatterns = [ - path('admin/', admin.site.urls), - path('', include('infoscreen.urls')) -] +urlpatterns = [path('admin/', admin.site.urls), path('', include('infoscreen.urls'))] urlpatterns += static(prefix=settings.STATIC_URL, document_root=settings.STATIC_ROOT) - if settings.DEBUG: urlpatterns += [ path('__debug__/', include(debug_toolbar.urls)), - ] \ No newline at end of file + ] From 1835c9b8cc26c6bd0deef12d93986f40cbbd1950 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Thu, 21 Apr 2022 19:56:19 +0200 Subject: [PATCH 05/41] fix linting errors for choices.py, /fields/__init__, weekday.py --- infoscreen/constants/choices.py | 13 ++----------- infoscreen/models/fields/__init__.py | 2 +- infoscreen/models/fields/weekday.py | 10 +++++----- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/infoscreen/constants/choices.py b/infoscreen/constants/choices.py index 82a8088..d7b90bf 100644 --- a/infoscreen/constants/choices.py +++ b/infoscreen/constants/choices.py @@ -1,4 +1,3 @@ - class Weekday: MON = 0 TUE = 1 @@ -7,13 +6,5 @@ class Weekday: FRI = 4 SAT = 5 SUN = 6 - - CHOICES = [ - (MON, "Mandag"), - (TUE, "Tirsdag"), - (WED, "Onsdag"), - (THU, "Torsdag"), - (FRI, "Fredag"), - (SAT, "Lørdag"), - (SUN, "Søndag") - ] \ No newline at end of file + + CHOICES = [(MON, 'Mandag'), (TUE, 'Tirsdag'), (WED, 'Onsdag'), (THU, 'Torsdag'), (FRI, 'Fredag'), (SAT, 'Lørdag'), (SUN, 'Søndag')] diff --git a/infoscreen/models/fields/__init__.py b/infoscreen/models/fields/__init__.py index f4073f3..700b04c 100644 --- a/infoscreen/models/fields/__init__.py +++ b/infoscreen/models/fields/__init__.py @@ -1,2 +1,2 @@ from .restricted_file import ContentTypeRestrictedFileField -# from .weekday import WeekdayField \ No newline at end of file +# from .weekday import WeekdayField diff --git a/infoscreen/models/fields/weekday.py b/infoscreen/models/fields/weekday.py index 16d3c13..703d88d 100644 --- a/infoscreen/models/fields/weekday.py +++ b/infoscreen/models/fields/weekday.py @@ -1,15 +1,15 @@ # from django.db.models import IntegerField -# +# # class WeekDayField(IntegerField): -# +# # def __init__(self, *args, **kwargs): # kwargs['choices'] = self.DAYS # super().__init__(*args, **kwargs) -# -# def clean(self, *args, **kwargs): +# +# def clean(self, *args, **kwargs): # data = super().clean(*args, **kwargs) # try: # if data and 0 > data > 6: raise forms.ValidationError(_('Ikke eksisterende ')) # except AttributeError: -# pass +# pass # return data From a4dabe59d1f2b19ceb1efd9209f61f1682a5c0f2 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 18:44:24 +0200 Subject: [PATCH 06/41] Change pylint disable codes to names --- root/models/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/root/models/base.py b/root/models/base.py index aa09698..4c5dc6a 100644 --- a/root/models/base.py +++ b/root/models/base.py @@ -25,9 +25,9 @@ def save(self, commit=True, *args, **kwargs): is saved manually at a later time. Return the model instance. """ # pylint: disable=invalid-string-quote - # pylint: disable=W0212 - # pylint: disable=C0209 - # pylint: disable=W0201 + # pylint: disable=protected-access + # pylint: disable=consider-using-f-string + # pylint: disable=attribute-defined-outside-init if self.errors: raise ValueError('The %s could not be %s because the data didn\'t validate.' % ( self.instance._meta.object_name, @@ -54,7 +54,7 @@ class CustomBaseAdmin(admin.ModelAdmin): # search_fields = [] def save_model(self, request, obj, form, change): - # pylint: disable=W0703 + # pylint: disable=broad-except try: if not change: obj.creator = request.user From ef09acb5a08092ca765e4bd02f453d71f1b26d39 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:02:03 +0200 Subject: [PATCH 07/41] Fix more pylint errors --- infoscreen/apps.py | 5 ++--- infoscreen/models/color.py | 1 + infoscreen/models/fields/restricted_file.py | 9 +++++---- infoscreen/models/tag.py | 5 ----- infoscreen/tests/tests.py | 2 -- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/infoscreen/apps.py b/infoscreen/apps.py index c7b5062..273d216 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -1,4 +1,5 @@ from django.apps import AppConfig +from django.core import management class InfoScreenConfig(AppConfig): @@ -6,9 +7,7 @@ class InfoScreenConfig(AppConfig): name = 'infoscreen' def ready(self): - - from django.core import management - + # pylint: disable=bare-except try: # https://docs.djangoproject.com/en/3.0/ref/django-admin/#createsuperuser management.call_command('createsuperuser', interactive=False) diff --git a/infoscreen/models/color.py b/infoscreen/models/color.py index a60fe09..acdc44d 100644 --- a/infoscreen/models/color.py +++ b/infoscreen/models/color.py @@ -22,6 +22,7 @@ def get_name(self): return self.hex def as_css(self): + # pylint: disable=fixme # TODO: handle COLOR_RANDOM # if self.name == root_constants.COLOR_RANDOM: # return diff --git a/infoscreen/models/fields/restricted_file.py b/infoscreen/models/fields/restricted_file.py index 30589c0..eb283b8 100644 --- a/infoscreen/models/fields/restricted_file.py +++ b/infoscreen/models/fields/restricted_file.py @@ -15,12 +15,13 @@ class ContentTypeRestrictedFileField(FileField): 250MB - 214958080 500MB - 429916160 """ - def __init__(self, content_types=None, max_upload_size=5242880,*args, **kwargs): + + def __init__(self, content_types=None, max_upload_size=5242880, *args, **kwargs): super().__init__(*args, **kwargs) self.content_types = content_types self.max_upload_size = max_upload_size - def clean(self, *args, **kwargs): + def clean(self, *args, **kwargs): data = super().clean(*args, **kwargs) file = data.file @@ -32,6 +33,6 @@ def clean(self, *args, **kwargs): else: raise forms.ValidationError(_('Filetype ikke støttet.')) except AttributeError: - pass + pass - return data \ No newline at end of file + return data diff --git a/infoscreen/models/tag.py b/infoscreen/models/tag.py index 2c21a16..bf76f56 100644 --- a/infoscreen/models/tag.py +++ b/infoscreen/models/tag.py @@ -1,10 +1,5 @@ # imports -import re - from django.db import models -from django.db.models import Q -from django.core.exceptions import NON_FIELD_ERRORS, ValidationError - from root import models as root_models # End: imports ----------------------------------------------------------------- diff --git a/infoscreen/tests/tests.py b/infoscreen/tests/tests.py index 7ce503c..a39b155 100644 --- a/infoscreen/tests/tests.py +++ b/infoscreen/tests/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. From 69847097cd9158bdc926e5397dd358dd2c41925f Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:05:16 +0200 Subject: [PATCH 08/41] Remove eval function from heroku.py --- root/settings/heroku.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/root/settings/heroku.py b/root/settings/heroku.py index f9eef0c..0ec8983 100644 --- a/root/settings/heroku.py +++ b/root/settings/heroku.py @@ -1,7 +1,6 @@ # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import import os -from ast import literal_eval import django_heroku from .base import * @@ -9,7 +8,10 @@ # Values are set in heroku dashboard SECRET_KEY = os.environ['SECRET_KEY'] -DEBUG = literal_eval(os.environ['DEBUG']) +if os.environ['DEBUG'] == 'True': + DEBUG = True +else: + DEBUG = False # pylint: disable=undefined-variable # Ensure correct ENV From d68104b7f72d214c230364aa58752506b645d3c3 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:24:01 +0200 Subject: [PATCH 09/41] fix final pylint errors --- infoscreen/models/fields/restricted_file.py | 6 +++++- infoscreen/models/tag.py | 8 ++++---- root/settings/heroku.py | 5 +---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/infoscreen/models/fields/restricted_file.py b/infoscreen/models/fields/restricted_file.py index eb283b8..ad37c05 100644 --- a/infoscreen/models/fields/restricted_file.py +++ b/infoscreen/models/fields/restricted_file.py @@ -1,4 +1,7 @@ from django.db.models import FileField +from django import forms +from django.template.defaultfilters import filesizeformat +from django.utils.translation import gettext_lazy as _ class ContentTypeRestrictedFileField(FileField): @@ -16,7 +19,7 @@ class ContentTypeRestrictedFileField(FileField): 500MB - 429916160 """ - def __init__(self, content_types=None, max_upload_size=5242880, *args, **kwargs): + def __init__(self, *args, content_types=None, max_upload_size=5242880, **kwargs): super().__init__(*args, **kwargs) self.content_types = content_types self.max_upload_size = max_upload_size @@ -24,6 +27,7 @@ def __init__(self, content_types=None, max_upload_size=5242880, *args, **kwargs) def clean(self, *args, **kwargs): data = super().clean(*args, **kwargs) + # pylint: disable=protected-access file = data.file try: content_type = file.content_type diff --git a/infoscreen/models/tag.py b/infoscreen/models/tag.py index bf76f56..d7376f2 100644 --- a/infoscreen/models/tag.py +++ b/infoscreen/models/tag.py @@ -29,10 +29,10 @@ def full_name(self): def color_list(self): """Hierarchical list of colors from least to most significant""" colors = [] - if self.tag_group: - colors += self.tag_group.color_list() - if self.color: - colors.append(self.color) + if self.group: + colors += self.group.color_list() + if self.bg: + colors.append(self.bg) return colors def color_list_css(self): diff --git a/root/settings/heroku.py b/root/settings/heroku.py index 0ec8983..13d1163 100644 --- a/root/settings/heroku.py +++ b/root/settings/heroku.py @@ -8,10 +8,7 @@ # Values are set in heroku dashboard SECRET_KEY = os.environ['SECRET_KEY'] -if os.environ['DEBUG'] == 'True': - DEBUG = True -else: - DEBUG = False +DEBUG = os.environ['DEBUG'] == True # pylint: disable=undefined-variable # Ensure correct ENV From 6b928a8e9ff3465094a637623a1c22b558c8b892 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:25:56 +0200 Subject: [PATCH 10/41] fix final pylint error --- root/settings/heroku.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/settings/heroku.py b/root/settings/heroku.py index 13d1163..9f64051 100644 --- a/root/settings/heroku.py +++ b/root/settings/heroku.py @@ -8,7 +8,7 @@ # Values are set in heroku dashboard SECRET_KEY = os.environ['SECRET_KEY'] -DEBUG = os.environ['DEBUG'] == True +DEBUG = os.environ['DEBUG'] == 'True' # pylint: disable=undefined-variable # Ensure correct ENV From 79f7de54182badea03e5bf0d3f09e9a67b59d9c1 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:31:28 +0200 Subject: [PATCH 11/41] remove help_text for Tag class --- infoscreen/models/tag.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/infoscreen/models/tag.py b/infoscreen/models/tag.py index d7376f2..040070f 100644 --- a/infoscreen/models/tag.py +++ b/infoscreen/models/tag.py @@ -6,9 +6,7 @@ class Tag(root_models.CustomBaseModel): - name = models.CharField( - max_length=200, unique=True, null=False, blank=False, verbose_name='navn', help_text='En vilkårlig egenskap til en plante. (Tips: Du kan prefikse tags med kolon ":", f.eks. "familie:fiola" )' - ) + name = models.CharField(max_length=200, unique=True, null=False, blank=False, verbose_name='navn') bg = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_bg', verbose_name='bakgrunnsfarge') font = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_font', verbose_name='skriftfarge') group = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, related_name='children', verbose_name='gruppe') From b468c8055a9de93a327b9d75bffe110ce3ec8285 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:34:02 +0200 Subject: [PATCH 12/41] add trailing comma for lists in tag.py --- infoscreen/models/tag.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/infoscreen/models/tag.py b/infoscreen/models/tag.py index 040070f..833cd4f 100644 --- a/infoscreen/models/tag.py +++ b/infoscreen/models/tag.py @@ -6,10 +6,37 @@ class Tag(root_models.CustomBaseModel): - name = models.CharField(max_length=200, unique=True, null=False, blank=False, verbose_name='navn') - bg = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_bg', verbose_name='bakgrunnsfarge') - font = models.ForeignKey('infoscreen.Color', on_delete=models.SET_NULL, null=True, blank=True, related_name='tag_font', verbose_name='skriftfarge') - group = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, related_name='children', verbose_name='gruppe') + name = models.CharField( + max_length=200, + unique=True, + null=False, + blank=False, + verbose_name='navn', + ) + bg = models.ForeignKey( + 'infoscreen.Color', + on_delete=models.SET_NULL, + null=True, + blank=True, + related_name='tag_bg', + verbose_name='bakgrunnsfarge', + ) + font = models.ForeignKey( + 'infoscreen.Color', + on_delete=models.SET_NULL, + null=True, + blank=True, + related_name='tag_font', + verbose_name='skriftfarge', + ) + group = models.ForeignKey( + 'self', + on_delete=models.SET_NULL, + null=True, + blank=True, + related_name='children', + verbose_name='gruppe', + ) class Meta: ordering = [] From b0bcc49f4b7329bb1b7c4c6ee32ae57cb039ecff Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:35:25 +0200 Subject: [PATCH 13/41] added trailing comma to urls.py --- root/urls.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/root/urls.py b/root/urls.py index c3f63fc..1075e49 100644 --- a/root/urls.py +++ b/root/urls.py @@ -20,7 +20,10 @@ from django.contrib import admin from django.conf.urls.static import static -urlpatterns = [path('admin/', admin.site.urls), path('', include('infoscreen.urls'))] +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('infoscreen.urls')), +] urlpatterns += static(prefix=settings.STATIC_URL, document_root=settings.STATIC_ROOT) From b6f33be76c06cc86a97a5ef2e026f5b70b6642e8 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:39:29 +0200 Subject: [PATCH 14/41] Add specific exception to apps.py --- infoscreen/apps.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/infoscreen/apps.py b/infoscreen/apps.py index 273d216..f98e670 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -7,9 +7,8 @@ class InfoScreenConfig(AppConfig): name = 'infoscreen' def ready(self): - # pylint: disable=bare-except try: # https://docs.djangoproject.com/en/3.0/ref/django-admin/#createsuperuser management.call_command('createsuperuser', interactive=False) - except: + except management.CommandError: pass From bb0ddfb883af8f49d8fef318a98d7a78cfbc394e Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 19:41:52 +0200 Subject: [PATCH 15/41] disable fixme from pylint --- .pylintrc | 1 + infoscreen/models/color.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 2e13b3c..586f647 100644 --- a/.pylintrc +++ b/.pylintrc @@ -23,6 +23,7 @@ disable= too-many-locals, too-many-statements, unsubscriptable-object, # https://github.com/PyCQA/pylint/issues/1498 + fixme, [VARIABLES] diff --git a/infoscreen/models/color.py b/infoscreen/models/color.py index acdc44d..a60fe09 100644 --- a/infoscreen/models/color.py +++ b/infoscreen/models/color.py @@ -22,7 +22,6 @@ def get_name(self): return self.hex def as_css(self): - # pylint: disable=fixme # TODO: handle COLOR_RANDOM # if self.name == root_constants.COLOR_RANDOM: # return From 443fd8de416c7fe9d9906c0251c2a38cfa05f630 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 20:01:02 +0200 Subject: [PATCH 16/41] fix migrate bug --- infoscreen/migrations/0003_alter_tag_name.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 infoscreen/migrations/0003_alter_tag_name.py diff --git a/infoscreen/migrations/0003_alter_tag_name.py b/infoscreen/migrations/0003_alter_tag_name.py new file mode 100644 index 0000000..8c65e5c --- /dev/null +++ b/infoscreen/migrations/0003_alter_tag_name.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2022-04-26 17:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('infoscreen', '0002_auto_20211109_1854'), + ] + + operations = [ + migrations.AlterField( + model_name='tag', + name='name', + field=models.CharField(max_length=200, unique=True, verbose_name='navn'), + ), + ] From 0811664eae8b11fe730686d6d7e417b246f449c3 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 20:19:06 +0200 Subject: [PATCH 17/41] fix error with github tests --- .pylintrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pylintrc b/.pylintrc index 586f647..9911871 100644 --- a/.pylintrc +++ b/.pylintrc @@ -27,6 +27,10 @@ disable= [VARIABLES] +[pylint-django] +django-settings-module=root.settings + + [pylint-quotes] string-quote=single-avoid-escape triple-quote=double From 13a4756d19b3de2417b777c6d39cb2e85a430313 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 20:37:50 +0200 Subject: [PATCH 18/41] fix error with github tests --- .pylintrc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.pylintrc b/.pylintrc index 9911871..772b198 100644 --- a/.pylintrc +++ b/.pylintrc @@ -9,6 +9,10 @@ argument-rgx=(([a-z_]+[a-z0-9_]*)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$ method-rgx=(([a-z_]+[a-z0-9_]*)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$ attr-rgx=(([a-z_]+[a-z0-9_]*)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$ +[pylint-django] +django-settings-module=root.settings + + [MESSAGES CONTROL] disable= @@ -24,13 +28,10 @@ disable= too-many-statements, unsubscriptable-object, # https://github.com/PyCQA/pylint/issues/1498 fixme, + django-not-configured, # django-settings-module=root.settings doesn't work [VARIABLES] -[pylint-django] -django-settings-module=root.settings - - [pylint-quotes] string-quote=single-avoid-escape triple-quote=double From bd767ebebc86c1ed153979c57d8d1755697b2d9b Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 20:40:36 +0200 Subject: [PATCH 19/41] copy fix from rekenett for github tests --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 772b198..760adc6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -28,7 +28,7 @@ disable= too-many-statements, unsubscriptable-object, # https://github.com/PyCQA/pylint/issues/1498 fixme, - django-not-configured, # django-settings-module=root.settings doesn't work + ; django-not-configured, # django-settings-module=root.settings doesn't work [VARIABLES] From 351a5410d02213c7591fa9456f285fc98739f683 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 20:55:13 +0200 Subject: [PATCH 20/41] run migrate before pylint in django.yml' --- .github/workflows/django.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 2fd9a9d..1a2eb3e 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -2,12 +2,12 @@ name: Django CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] # Prevent multiple workflows with same branch/pull_request -concurrency: +concurrency: group: ${{ github.ref_name }} cancel-in-progress: true @@ -20,17 +20,16 @@ env: DJANGO_SUPERUSER_EMAIL: admin@example.com jobs: - job_build_django: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.7.5' # Closest version to 3.7.3 available. - + - name: Install dependencies run: | python -V @@ -39,12 +38,13 @@ jobs: python -m pip install --upgrade pip python -m pip install pipenv python -m pipenv install --python $PY - - - name: Run pylint - run: python -m pipenv run pylint infoscreen root - name: Verify migrations run: | python -m pipenv run python manage.py migrate + + - name: Run pylint + run: python -m pipenv run pylint infoscreen root + - name: Run tests run: python -m pipenv run pytest From 576cad0d7b14318f10b4e0fc859c34005b574fa1 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 21:12:44 +0200 Subject: [PATCH 21/41] add settings config to apps.py --- .github/workflows/django.yml | 6 +++--- infoscreen/apps.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 1a2eb3e..bfa5a3c 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -39,12 +39,12 @@ jobs: python -m pip install pipenv python -m pipenv install --python $PY + - name: Run pylint + run: python -m pipenv run pylint infoscreen root + - name: Verify migrations run: | python -m pipenv run python manage.py migrate - - name: Run pylint - run: python -m pipenv run pylint infoscreen root - - name: Run tests run: python -m pipenv run pytest diff --git a/infoscreen/apps.py b/infoscreen/apps.py index f98e670..c532806 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -1,3 +1,11 @@ +import os + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") + +import django + +django.setup() + from django.apps import AppConfig from django.core import management From 5dfa0d649ad6310d2f6fcc120a869fd8ad32d28c Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 21:20:25 +0200 Subject: [PATCH 22/41] remove introduced error in apps.py --- infoscreen/apps.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/infoscreen/apps.py b/infoscreen/apps.py index c532806..f98e670 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -1,11 +1,3 @@ -import os - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - -import django - -django.setup() - from django.apps import AppConfig from django.core import management From f64388de62e87708b91a4ff999b0ff601f5421be Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 26 Apr 2022 21:45:39 +0200 Subject: [PATCH 23/41] add DJANGO_SETTINGS_MODULE to yml script --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index bfa5a3c..b1cac12 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -18,6 +18,7 @@ env: DJANGO_SUPERUSER_USERNAME: admin DJANGO_SUPERUSER_PASSWORD: Django123 DJANGO_SUPERUSER_EMAIL: admin@example.com + DJANGO_SETTINGS_MODULE: root.settings jobs: job_build_django: From 78b200c3a00f102c828512c8763cdd014bd7c928 Mon Sep 17 00:00:00 2001 From: Sindre Lothe <31065755+sindrelothe@users.noreply.github.com> Date: Tue, 26 Apr 2022 21:51:29 +0200 Subject: [PATCH 24/41] Update django.yml --- .github/workflows/django.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index b1cac12..ff32c23 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -40,12 +40,6 @@ jobs: python -m pip install pipenv python -m pipenv install --python $PY - - name: Run pylint - run: python -m pipenv run pylint infoscreen root - - - name: Verify migrations - run: | - python -m pipenv run python manage.py migrate - name: Run tests run: python -m pipenv run pytest From e0581c103b3dcc696de9ec81bd736bab4a52127b Mon Sep 17 00:00:00 2001 From: Sindre Lothe <31065755+sindrelothe@users.noreply.github.com> Date: Tue, 26 Apr 2022 21:59:30 +0200 Subject: [PATCH 25/41] Update django.yml --- .github/workflows/django.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index ff32c23..b1cac12 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -40,6 +40,12 @@ jobs: python -m pip install pipenv python -m pipenv install --python $PY + - name: Run pylint + run: python -m pipenv run pylint infoscreen root + + - name: Verify migrations + run: | + python -m pipenv run python manage.py migrate - name: Run tests run: python -m pipenv run pytest From 2cf9ff5203262ab232fcdbf85b74f92d500cc475 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 23 Aug 2022 19:31:20 +0200 Subject: [PATCH 26/41] add new line --- infoscreen/templates/infoscreen/screen.html | 1 + 1 file changed, 1 insertion(+) diff --git a/infoscreen/templates/infoscreen/screen.html b/infoscreen/templates/infoscreen/screen.html index fb8619c..40a992a 100644 --- a/infoscreen/templates/infoscreen/screen.html +++ b/infoscreen/templates/infoscreen/screen.html @@ -41,3 +41,4 @@ {% endblock %} + From ba0bcd24a9abcfea43dd6726b5ced7e4eb633f52 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 23 Aug 2022 19:53:12 +0200 Subject: [PATCH 27/41] fix pipeline --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index b1cac12..77ff64c 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -41,6 +41,7 @@ jobs: python -m pipenv install --python $PY - name: Run pylint + run: python -m pipenv manage.py migrate run: python -m pipenv run pylint infoscreen root - name: Verify migrations From 7df6683b118f923b381b85100c03a07c5a90e9cd Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 23 Aug 2022 19:57:01 +0200 Subject: [PATCH 28/41] fix pipeline --- .github/workflows/django.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 77ff64c..eca47df 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -41,8 +41,9 @@ jobs: python -m pipenv install --python $PY - name: Run pylint - run: python -m pipenv manage.py migrate - run: python -m pipenv run pylint infoscreen root + run: | + python -m pipenv manage.py migrate + python -m pipenv run pylint infoscreen root - name: Verify migrations run: | From 9111c6d1785819a21b1d141c3694995a9e5537bf Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 23 Aug 2022 20:01:08 +0200 Subject: [PATCH 29/41] move verify migrations to before run pylint in yml --- .github/workflows/django.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index eca47df..ca487d3 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -40,14 +40,12 @@ jobs: python -m pip install pipenv python -m pipenv install --python $PY - - name: Run pylint - run: | - python -m pipenv manage.py migrate - python -m pipenv run pylint infoscreen root - - name: Verify migrations run: | python -m pipenv run python manage.py migrate + - name: Run pylint + run: python -m pipenv run pylint infoscreen root + - name: Run tests run: python -m pipenv run pytest From 4946d497c3912378ed84fdcac7cfd386667d3226 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 23 Aug 2022 20:43:35 +0200 Subject: [PATCH 30/41] add makemigrations to yml --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index ca487d3..fccc875 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -42,6 +42,7 @@ jobs: - name: Verify migrations run: | + python -m pipenv run python manage.py makemigrations --check --dry-runs python -m pipenv run python manage.py migrate - name: Run pylint From 31c5fe41e181e7cbc3b42a1af2250608b8f9dfc6 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 18:34:05 +0200 Subject: [PATCH 31/41] fix merge conflicts --- infoscreen/apps.py | 7 ------- root/models/base.py | 3 --- 2 files changed, 10 deletions(-) diff --git a/infoscreen/apps.py b/infoscreen/apps.py index 4cff949..b88adf5 100644 --- a/infoscreen/apps.py +++ b/infoscreen/apps.py @@ -7,12 +7,6 @@ class InfoScreenConfig(AppConfig): name = 'infoscreen' def ready(self): -<<<<<<< HEAD - try: - # https://docs.djangoproject.com/en/3.0/ref/django-admin/#createsuperuser - management.call_command('createsuperuser', interactive=False) - except management.CommandError: -======= from django.core import management @@ -20,5 +14,4 @@ def ready(self): # https://docs.djangoproject.com/en/3.0/ref/django-admin/#createsuperuser management.call_command('createsuperuser', interactive=False) except: ->>>>>>> 035aec60c9b1249ca1761f39c5fdafbc26602740 pass diff --git a/root/models/base.py b/root/models/base.py index 1900c7e..173f1cd 100644 --- a/root/models/base.py +++ b/root/models/base.py @@ -6,10 +6,7 @@ from django.utils import timezone from django.contrib import admin from django.contrib.auth import models as auth_models -<<<<<<< HEAD -======= from django.template.defaultfilters import filesizeformat ->>>>>>> 035aec60c9b1249ca1761f39c5fdafbc26602740 # End: imports ----------------------------------------------------------------- From e859ea0c0b0330b2ef16c499c4b999bfe310a6a1 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 18:34:57 +0200 Subject: [PATCH 32/41] fix merge conflicts --- root/models/base.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/root/models/base.py b/root/models/base.py index 173f1cd..42a4ff6 100644 --- a/root/models/base.py +++ b/root/models/base.py @@ -30,11 +30,7 @@ def save(self, commit=True, *args, **kwargs): # pylint: disable=consider-using-f-string # pylint: disable=attribute-defined-outside-init if self.errors: -<<<<<<< HEAD - raise ValueError('The %s could not be %s because the data didn\'t validate.' % ( -======= raise ValueError("The %s could not be %s because the data didn't validate." % ( ->>>>>>> 035aec60c9b1249ca1761f39c5fdafbc26602740 self.instance._meta.object_name, 'created' if self.instance._state.adding else 'changed', )) @@ -82,11 +78,7 @@ class Meta: abstract = True def is_edited(self): -<<<<<<< HEAD - return self.created != self.last_edited -======= return (self.created != self.last_edited) ->>>>>>> 035aec60c9b1249ca1761f39c5fdafbc26602740 def clean(self, *args, **kwargs): pass From ba5254f62efe5763b76bc5eb9002ce44c9a95d78 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 18:55:38 +0200 Subject: [PATCH 33/41] update python version in django.yml --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index fccc875..050e66b 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -29,7 +29,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.7.5' # Closest version to 3.7.3 available. + python-version: '3.9.2' # Closest version to 3.7.3 available. - name: Install dependencies run: | From 4d1d07ef186fa9131750097a2d313c541b2fbfda Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 18:58:33 +0200 Subject: [PATCH 34/41] remove arguments from 'makemigrations' in djano.yml --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 050e66b..3b97164 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -42,7 +42,7 @@ jobs: - name: Verify migrations run: | - python -m pipenv run python manage.py makemigrations --check --dry-runs + python -m pipenv run python manage.py makemigrations python -m pipenv run python manage.py migrate - name: Run pylint From a1fba8684b3a93460661dbeb5c062da34328223d Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:17:02 +0200 Subject: [PATCH 35/41] remove migrations file --- infoscreen/migrations/0003_alter_tag_name.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 infoscreen/migrations/0003_alter_tag_name.py diff --git a/infoscreen/migrations/0003_alter_tag_name.py b/infoscreen/migrations/0003_alter_tag_name.py deleted file mode 100644 index 8c65e5c..0000000 --- a/infoscreen/migrations/0003_alter_tag_name.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.12 on 2022-04-26 17:58 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('infoscreen', '0002_auto_20211109_1854'), - ] - - operations = [ - migrations.AlterField( - model_name='tag', - name='name', - field=models.CharField(max_length=200, unique=True, verbose_name='navn'), - ), - ] From a0588f9f0d3d01cab415391b95d3d67a39023b81 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:32:15 +0200 Subject: [PATCH 36/41] remove pylint from django.yml --- .github/workflows/django.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 3b97164..3e0a91b 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -45,8 +45,8 @@ jobs: python -m pipenv run python manage.py makemigrations python -m pipenv run python manage.py migrate - - name: Run pylint - run: python -m pipenv run pylint infoscreen root + # - name: Run pylint + # run: python -m pipenv run pylint infoscreen root - name: Run tests run: python -m pipenv run pytest From 095ba2948b62899f9081b4c19c0f1e01f1fe5ece Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:38:13 +0200 Subject: [PATCH 37/41] remove run pytest from infoscreen --- .github/workflows/django.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 3e0a91b..cc44904 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -47,6 +47,3 @@ jobs: # - name: Run pylint # run: python -m pipenv run pylint infoscreen root - - - name: Run tests - run: python -m pipenv run pytest From b018e3164058203959ccf7a864ae125fe5167fb6 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:48:39 +0200 Subject: [PATCH 38/41] add linting to django.yml --- .github/workflows/django.yml | 4 ++-- run-pylint.sh | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 run-pylint.sh diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index cc44904..9a5c93f 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -45,5 +45,5 @@ jobs: python -m pipenv run python manage.py makemigrations python -m pipenv run python manage.py migrate - # - name: Run pylint - # run: python -m pipenv run pylint infoscreen root + - name: Run pylint + run: python -m pipenv run pylint ./run-pylint.sh diff --git a/run-pylint.sh b/run-pylint.sh new file mode 100644 index 0000000..e50f4f7 --- /dev/null +++ b/run-pylint.sh @@ -0,0 +1,5 @@ +#! /bin/bash +PROJECT_DIR=$(pwd) +PYTHONPATH="$PROJECT_DIR:$PYTHONPATH" +echo "PYTHONPATH=$PYTHONPATH" +PYTHONPATH=$PYTHONPATH pylint infoscreen root From ab1d4b35e76b9c4b296cc5e9afaaad7aa0ef9032 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:54:53 +0200 Subject: [PATCH 39/41] remove linting of root --- run-pylint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-pylint.sh b/run-pylint.sh index e50f4f7..01b81bc 100644 --- a/run-pylint.sh +++ b/run-pylint.sh @@ -2,4 +2,4 @@ PROJECT_DIR=$(pwd) PYTHONPATH="$PROJECT_DIR:$PYTHONPATH" echo "PYTHONPATH=$PYTHONPATH" -PYTHONPATH=$PYTHONPATH pylint infoscreen root +PYTHONPATH=$PYTHONPATH pylint infoscreen From 556722ffb9aea5b8d0197f8f96e07f1b92d7c777 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 19:58:37 +0200 Subject: [PATCH 40/41] remove linting of root --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 9a5c93f..a3dd24e 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -46,4 +46,4 @@ jobs: python -m pipenv run python manage.py migrate - name: Run pylint - run: python -m pipenv run pylint ./run-pylint.sh + run: python -m pipenv run pylint infoscreen From 0c2bd5fb2cf528b9f60d86f17e81747cb36434f6 Mon Sep 17 00:00:00 2001 From: sindrelothe Date: Tue, 27 Sep 2022 20:10:47 +0200 Subject: [PATCH 41/41] use .sh structure to lint --- .github/workflows/django.yml | 2 +- run-pylint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index a3dd24e..9a5c93f 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -46,4 +46,4 @@ jobs: python -m pipenv run python manage.py migrate - name: Run pylint - run: python -m pipenv run pylint infoscreen + run: python -m pipenv run pylint ./run-pylint.sh diff --git a/run-pylint.sh b/run-pylint.sh index 01b81bc..e50f4f7 100644 --- a/run-pylint.sh +++ b/run-pylint.sh @@ -2,4 +2,4 @@ PROJECT_DIR=$(pwd) PYTHONPATH="$PROJECT_DIR:$PYTHONPATH" echo "PYTHONPATH=$PYTHONPATH" -PYTHONPATH=$PYTHONPATH pylint infoscreen +PYTHONPATH=$PYTHONPATH pylint infoscreen root