From e8cc9915f350926b92d279641350387e3b5bb07f Mon Sep 17 00:00:00 2001 From: Cybernetic-Ransomware <71835339+Cybernetic-Ransomware@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:10:49 +0200 Subject: [PATCH 1/4] first changes to absolute imports --- .../AHC_app/celery_notifications/config.py | 4 +-- AHC_app/animals/apps.py | 2 +- AHC_app/animals/forms.py | 3 +- .../mixins/animal_owner_permissions.py | 3 +- AHC_app/animals/models.py | 3 +- AHC_app/animals/signals.py | 20 ++++-------- AHC_app/animals/urls.py | 5 +-- AHC_app/animals/utils_owner/forms.py | 20 ++++-------- AHC_app/animals/utils_owner/views.py | 19 +++++------ AHC_app/animals/views.py | 7 ++-- AHC_app/docker-compose.yml | 4 ++- AHC_app/homepage/admin.py | 2 +- .../management/commands/sync_cronjobs.py | 7 ++-- AHC_app/homepage/models.py | 3 +- AHC_app/homepage/tests/test_homepage.py | 3 +- AHC_app/homepage/urls.py | 2 +- AHC_app/homepage/views.py | 5 +-- AHC_app/medical_notes/forms.py | 2 -- .../medical_notes/forms/type_basic_note.py | 5 ++- .../medical_notes/forms/type_feeding_notes.py | 6 +++- .../medical_notes/models/type_basic_note.py | 5 +-- .../signals/type_feeding_notes.py | 9 +++--- .../signals/type_measurement_notes.py | 15 ++++----- .../templatetags/custom_file_name.py | 3 +- AHC_app/medical_notes/urls.py | 7 ++-- .../medical_notes/views/type_basic_note.py | 10 ++++-- .../medical_notes/views/type_feeding_notes.py | 12 ++++--- .../views/type_measurement_notes.py | 17 ++++------ AHC_app/users/admin.py | 2 +- AHC_app/users/forms.py | 2 +- AHC_app/users/models.py | 3 +- AHC_app/users/signals.py | 12 +++---- AHC_app/users/urls.py | 32 +++++++++++++++---- AHC_app/users/views.py | 6 ++-- 34 files changed, 140 insertions(+), 120 deletions(-) diff --git a/AHC_app/AHC_app/celery_notifications/config.py b/AHC_app/AHC_app/celery_notifications/config.py index 7a3c94e..9db2eea 100644 --- a/AHC_app/AHC_app/celery_notifications/config.py +++ b/AHC_app/AHC_app/celery_notifications/config.py @@ -4,8 +4,8 @@ from celery.utils.log import get_task_logger from django.conf import settings -from AHC_app.celery_notifications.utils.discord_utils import send_via_discord -from AHC_app.celery_notifications.utils.sending_utils import ( +from AHC_app.AHC_app.celery_notifications.utils.discord_utils import send_via_discord +from AHC_app.AHC_app.celery_notifications.utils.sending_utils import ( send_via_email, # , send_via_sms, send_via_discord ) diff --git a/AHC_app/animals/apps.py b/AHC_app/animals/apps.py index fef2b06..47778cd 100644 --- a/AHC_app/animals/apps.py +++ b/AHC_app/animals/apps.py @@ -6,4 +6,4 @@ class AnimalsConfig(AppConfig): name = "animals" def ready(self): - import animals.signals + pass diff --git a/AHC_app/animals/forms.py b/AHC_app/animals/forms.py index fa3d045..ac91ac5 100644 --- a/AHC_app/animals/forms.py +++ b/AHC_app/animals/forms.py @@ -1,8 +1,9 @@ -from animals.models import Animal from django import forms from django.core.validators import MaxLengthValidator, MinLengthValidator from django.db.models import Q +from AHC_app.animals.models import Animal + class AnimalRegisterForm(forms.ModelForm): class Meta: diff --git a/AHC_app/animals/mixins/animal_owner_permissions.py b/AHC_app/animals/mixins/animal_owner_permissions.py index 378f8c0..741c94b 100644 --- a/AHC_app/animals/mixins/animal_owner_permissions.py +++ b/AHC_app/animals/mixins/animal_owner_permissions.py @@ -1,6 +1,7 @@ -from animals.models import Animal from django.contrib.auth.mixins import UserPassesTestMixin +from AHC_app.animals.models import Animal + class UserPassesOwnershipTestMixin(UserPassesTestMixin): def test_func(self): diff --git a/AHC_app/animals/models.py b/AHC_app/animals/models.py index d64a8d1..95c24b7 100644 --- a/AHC_app/animals/models.py +++ b/AHC_app/animals/models.py @@ -1,7 +1,8 @@ import uuid from django.db import models -from users.models import Profile as UserProfile + +from AHC_app.users.models import Profile as UserProfile class Animal(models.Model): diff --git a/AHC_app/animals/signals.py b/AHC_app/animals/signals.py index 62fc846..256cd10 100644 --- a/AHC_app/animals/signals.py +++ b/AHC_app/animals/signals.py @@ -2,21 +2,17 @@ from django.db.models.signals import post_delete, post_save, pre_delete from django.dispatch import receiver -from users.models import Profile -from animals.models import Animal +from AHC_app.animals.models import Animal +from AHC_app.users.models import Profile @receiver(post_save, sender=Animal) def remove_old_pictures_after_change(sender, instance, **kwargs): - animals_with_profile_images = Animal.objects.exclude(profile_image="").values_list( - "profile_image", flat=True - ) + animals_with_profile_images = Animal.objects.exclude(profile_image="").values_list("profile_image", flat=True) unused_images = os.listdir("static/media/profile_pics/animals/") - animals_with_profile_images = [ - str(picture).split("/")[-1] for picture in animals_with_profile_images - ] + animals_with_profile_images = [str(picture).split("/")[-1] for picture in animals_with_profile_images] for image_name in unused_images: if image_name not in animals_with_profile_images: @@ -36,14 +32,10 @@ def remove_old_pictures_after_animal_delete(sender, instance, **kwargs): @receiver(post_delete, sender=Profile) def remove_old_pictures_after_user_delete(sender, instance, **kwargs): - animals_with_profile_images = Animal.objects.exclude(profile_image="").values_list( - "profile_image", flat=True - ) + animals_with_profile_images = Animal.objects.exclude(profile_image="").values_list("profile_image", flat=True) unused_images = os.listdir("static/media/profile_pics/animals/") - animals_with_profile_images = [ - str(picture).split("/")[-1] for picture in animals_with_profile_images - ] + animals_with_profile_images = [str(picture).split("/")[-1] for picture in animals_with_profile_images] for image_name in unused_images: if image_name not in animals_with_profile_images: diff --git a/AHC_app/animals/urls.py b/AHC_app/animals/urls.py index f741254..4d68d3d 100644 --- a/AHC_app/animals/urls.py +++ b/AHC_app/animals/urls.py @@ -1,7 +1,8 @@ -from animals import views as animal_views -from animals.utils_owner import views as animal_owner_views from django.urls import path +from AHC_app.animals import views as animal_views +from AHC_app.animals.utils_owner import views as animal_owner_views + urlpatterns = [ path("create/", animal_views.CreateAnimalView.as_view(), name="animal_create"), path("/delete/", animal_owner_views.AnimalDeleteView.as_view(), name="animal_delete"), diff --git a/AHC_app/animals/utils_owner/forms.py b/AHC_app/animals/utils_owner/forms.py index 0385cd3..dd302eb 100644 --- a/AHC_app/animals/utils_owner/forms.py +++ b/AHC_app/animals/utils_owner/forms.py @@ -2,9 +2,9 @@ from django import forms from PIL import Image -from users.models import Profile -from animals.models import Animal +from AHC_app.animals.models import Animal +from AHC_app.users.models import Profile class ImageUploadForm(forms.ModelForm): @@ -38,9 +38,7 @@ def clean_profile_image(self): class ChangeOwnerForm(forms.Form): - new_owner = forms.CharField( - max_length=255, required=True, label="New owner's profile name" - ) + new_owner = forms.CharField(max_length=255, required=True, label="New owner's profile name") set_keeper = forms.BooleanField(required=False, label="Set as keeper") def __init__(self, *args, **kwargs): @@ -63,9 +61,7 @@ def clean_new_owner(self): class ManageKeepersForm(forms.Form): - input_user = forms.CharField( - max_length=255, required=True, label="Full keeper profile name" - ) + input_user = forms.CharField(max_length=255, required=True, label="Full keeper profile name") def __init__(self, *args, **kwargs): self.instance = kwargs.pop("instance", None) @@ -75,9 +71,7 @@ def clean_input_user(self): input_user = self.cleaned_data.get("input_user") if input_user == self.instance.owner.user.username: - raise forms.ValidationError( - "As the owner you can not set yourself as a keeper." - ) + raise forms.ValidationError("As the owner you can not set yourself as a keeper.") if input_user in self.instance.allowed_users.all(): raise forms.ValidationError("User is already on the list of keepers.") @@ -101,9 +95,7 @@ def clean_birthdate(self): current_date = date.today() if birthdate > current_date: - raise forms.ValidationError( - "Date could not be set further than current day." - ) + raise forms.ValidationError("Date could not be set further than current day.") return birthdate diff --git a/AHC_app/animals/utils_owner/views.py b/AHC_app/animals/utils_owner/views.py index 963d817..26481ad 100644 --- a/AHC_app/animals/utils_owner/views.py +++ b/AHC_app/animals/utils_owner/views.py @@ -1,12 +1,3 @@ -from animals.mixins.animal_owner_permissions import UserPassesOwnershipTestMixin -from animals.models import Animal -from animals.utils_owner.forms import ( - ChangeBirthdayForm, - ChangeFirstContactForm, - ChangeOwnerForm, - ImageUploadForm, - ManageKeepersForm, -) from django.contrib.auth.mixins import LoginRequiredMixin from django.shortcuts import get_object_or_404, redirect from django.urls import reverse, reverse_lazy @@ -14,6 +5,16 @@ from django.views.generic.edit import FormView from PIL import Image +from AHC_app.animals.mixins.animal_owner_permissions import UserPassesOwnershipTestMixin +from AHC_app.animals.models import Animal +from AHC_app.animals.utils_owner.forms import ( + ChangeBirthdayForm, + ChangeFirstContactForm, + ChangeOwnerForm, + ImageUploadForm, + ManageKeepersForm, +) + class AnimalDeleteView(LoginRequiredMixin, UserPassesOwnershipTestMixin, DeleteView): model = Animal diff --git a/AHC_app/animals/views.py b/AHC_app/animals/views.py index 84f1c0b..a21d815 100644 --- a/AHC_app/animals/views.py +++ b/AHC_app/animals/views.py @@ -1,5 +1,3 @@ -from animals.forms import AnimalRegisterForm, PinAnimalForm -from animals.models import Animal from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.db.models import Q from django.http import JsonResponse @@ -8,7 +6,10 @@ from django.views.generic import TemplateView, View from django.views.generic.detail import DetailView from django.views.generic.edit import FormView -from medical_notes.models.type_basic_note import MedicalRecord + +from AHC_app.animals.forms import AnimalRegisterForm, PinAnimalForm +from AHC_app.animals.models import Animal +from AHC_app.medical_notes.models.type_basic_note import MedicalRecord # from users.models import Profile as UserProfile diff --git a/AHC_app/docker-compose.yml b/AHC_app/docker-compose.yml index 54ac5d3..eb0a894 100644 --- a/AHC_app/docker-compose.yml +++ b/AHC_app/docker-compose.yml @@ -16,7 +16,7 @@ services: condition: service_healthy environment: - PYTHONUNBUFFERED=1 - - PYTHONPATH=/AHC_app + - PYTHONPATH=/app entrypoint: ["/bin/bash", "-c"] command: - | @@ -84,6 +84,8 @@ services: - "5000:5000" environment: - DJANGO_SETTINGS_MODULE=AHC_app.settings + - PYTHONUNBUFFERED=1 + - PYTHONPATH=/app redis: image: redis:7-alpine diff --git a/AHC_app/homepage/admin.py b/AHC_app/homepage/admin.py index bc300d6..8ae0ccc 100644 --- a/AHC_app/homepage/admin.py +++ b/AHC_app/homepage/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from homepage.models import AnimalTitle, CronJob +from AHC_app.homepage.models import AnimalTitle, CronJob admin.site.register(AnimalTitle) diff --git a/AHC_app/homepage/management/commands/sync_cronjobs.py b/AHC_app/homepage/management/commands/sync_cronjobs.py index 5d13508..8935319 100644 --- a/AHC_app/homepage/management/commands/sync_cronjobs.py +++ b/AHC_app/homepage/management/commands/sync_cronjobs.py @@ -1,16 +1,15 @@ import subprocess from django.core.management.base import BaseCommand -from homepage.models import CronJob + +from AHC_app.homepage.models import CronJob class Command(BaseCommand): help = "Sync cronjobs with the actual cron configuration" def handle(self, *args, **options): - cronjob_info = subprocess.run( - ["crontab", "-l"], stdout=subprocess.PIPE, text=True - ).stdout.splitlines() + cronjob_info = subprocess.run(["crontab", "-l"], stdout=subprocess.PIPE, text=True).stdout.splitlines() CronJob.objects.all().delete() diff --git a/AHC_app/homepage/models.py b/AHC_app/homepage/models.py index fab7fc2..f872255 100644 --- a/AHC_app/homepage/models.py +++ b/AHC_app/homepage/models.py @@ -1,7 +1,8 @@ from django.contrib.auth.models import User from django.db import models from django.urls import reverse -from homepage.utils import ImageGenerator + +from AHC_app.homepage.utils import ImageGenerator class Privilege(models.Model): diff --git a/AHC_app/homepage/tests/test_homepage.py b/AHC_app/homepage/tests/test_homepage.py index dc91c82..a6af1b9 100644 --- a/AHC_app/homepage/tests/test_homepage.py +++ b/AHC_app/homepage/tests/test_homepage.py @@ -2,7 +2,8 @@ from django.contrib.auth.models import User from django.test import Client, TestCase -from homepage.models import AnimalTitle + +from AHC_app.homepage.models import AnimalTitle client = Client() diff --git a/AHC_app/homepage/urls.py b/AHC_app/homepage/urls.py index 30af557..604d2b8 100644 --- a/AHC_app/homepage/urls.py +++ b/AHC_app/homepage/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from homepage.views import HomepageView +from AHC_app.homepage.views import HomepageView urlpatterns = [ path("", HomepageView.as_view(), name="Homepage"), diff --git a/AHC_app/homepage/views.py b/AHC_app/homepage/views.py index 1a51f30..3fe3dbc 100644 --- a/AHC_app/homepage/views.py +++ b/AHC_app/homepage/views.py @@ -1,7 +1,8 @@ -from animals.models import Animal from django.db.models import Q from django.views.generic import TemplateView -from users.models import Profile as UserProfile + +from AHC_app.animals.models import Animal +from AHC_app.users.models import Profile as UserProfile class HomepageView(TemplateView): diff --git a/AHC_app/medical_notes/forms.py b/AHC_app/medical_notes/forms.py index 67e9a56..e69de29 100644 --- a/AHC_app/medical_notes/forms.py +++ b/AHC_app/medical_notes/forms.py @@ -1,2 +0,0 @@ -from medical_notes.forms.type_basic_note import * -from medical_notes.forms.type_measurement_notes import * diff --git a/AHC_app/medical_notes/forms/type_basic_note.py b/AHC_app/medical_notes/forms/type_basic_note.py index 8263457..cc2d342 100644 --- a/AHC_app/medical_notes/forms/type_basic_note.py +++ b/AHC_app/medical_notes/forms/type_basic_note.py @@ -1,7 +1,10 @@ from django import forms # from animals.models import Animal as AnimalProfile -from medical_notes.models.type_basic_note import MedicalRecord, MedicalRecordAttachment +from AHC_app.medical_notes.models.type_basic_note import ( + MedicalRecord, + MedicalRecordAttachment, +) # from django.core.validators import MaxLengthValidator, MinLengthValidator # from django.db.models import Q diff --git a/AHC_app/medical_notes/forms/type_feeding_notes.py b/AHC_app/medical_notes/forms/type_feeding_notes.py index 3e4fb4e..90197a3 100644 --- a/AHC_app/medical_notes/forms/type_feeding_notes.py +++ b/AHC_app/medical_notes/forms/type_feeding_notes.py @@ -1,8 +1,12 @@ from django import forms from django.conf import settings -from medical_notes.models.type_feeding_notes import EmailNotification, FeedingNote from timezone_field import TimeZoneFormField +from AHC_app.medical_notes.models.type_feeding_notes import ( + EmailNotification, + FeedingNote, +) + class DietRecordForm(forms.ModelForm): class Meta: diff --git a/AHC_app/medical_notes/models/type_basic_note.py b/AHC_app/medical_notes/models/type_basic_note.py index b5ce3d4..9fd581d 100644 --- a/AHC_app/medical_notes/models/type_basic_note.py +++ b/AHC_app/medical_notes/models/type_basic_note.py @@ -1,10 +1,11 @@ import uuid -from animals.models import Animal from django.db import models from taggit.managers import TaggableManager from taggit.models import GenericUUIDTaggedItemBase, TaggedItemBase -from users.models import Profile as UserProfile + +from AHC_app.animals.models import Animal +from AHC_app.users.models import Profile as UserProfile class UUIDTaggedItem(GenericUUIDTaggedItemBase, TaggedItemBase): diff --git a/AHC_app/medical_notes/signals/type_feeding_notes.py b/AHC_app/medical_notes/signals/type_feeding_notes.py index b6001c5..02f378e 100644 --- a/AHC_app/medical_notes/signals/type_feeding_notes.py +++ b/AHC_app/medical_notes/signals/type_feeding_notes.py @@ -1,15 +1,14 @@ from django.db import transaction from django.db.models.signals import post_save from django.dispatch import receiver -from medical_notes.models.type_feeding_notes import FeedingNote -from users.models import Profile as UserProfile + +from AHC_app.medical_notes.models.type_feeding_notes import FeedingNote +from AHC_app.users.models import Profile as UserProfile @receiver(post_save, sender=FeedingNote) def clean_orphaned_diet_records(sender, instance, **kwargs): user_profile = UserProfile.objects.get(id=instance.related_note.author.id) with transaction.atomic(): - orphaned_notes = FeedingNote.objects.filter( - author=user_profile, related_note=None - ) + orphaned_notes = FeedingNote.objects.filter(author=user_profile, related_note=None) orphaned_notes.delete() diff --git a/AHC_app/medical_notes/signals/type_measurement_notes.py b/AHC_app/medical_notes/signals/type_measurement_notes.py index f4fee9a..6c57a9c 100644 --- a/AHC_app/medical_notes/signals/type_measurement_notes.py +++ b/AHC_app/medical_notes/signals/type_measurement_notes.py @@ -2,9 +2,10 @@ from django.db.models import Q from django.db.models.signals import post_save, pre_save from django.dispatch import receiver -from medical_notes.models.type_basic_note import MedicalRecord -from medical_notes.models.type_measurement_notes import BiometricRecord -from users.models import Profile as UserProfile + +from AHC_app.medical_notes.models.type_basic_note import MedicalRecord +from AHC_app.medical_notes.models.type_measurement_notes import BiometricRecord +from AHC_app.users.models import Profile as UserProfile @receiver(pre_save, sender=BiometricRecord) @@ -23,17 +24,13 @@ def validate_one_to_one_fields(sender, instance, **kwargs): ) > 1 ): - raise ValidationError( - "BiometricRecord can only have one of OneToOneFields assigned." - ) + raise ValidationError("BiometricRecord can only have one of OneToOneFields assigned.") @receiver(post_save, sender=BiometricRecord) def clean_orphaned_metric_records(sender, instance, **kwargs): user_profile = UserProfile.objects.get(id=instance.related_note.author.id) - medical_records = MedicalRecord.objects.filter( - author=user_profile, type_of_event="biometric_record" - ) + medical_records = MedicalRecord.objects.filter(author=user_profile, type_of_event="biometric_record") for record in medical_records: if not record.biometricrecord_set.filter( diff --git a/AHC_app/medical_notes/templatetags/custom_file_name.py b/AHC_app/medical_notes/templatetags/custom_file_name.py index 82d6968..316e3bb 100644 --- a/AHC_app/medical_notes/templatetags/custom_file_name.py +++ b/AHC_app/medical_notes/templatetags/custom_file_name.py @@ -1,5 +1,6 @@ from django import template -from medical_notes.models.type_feeding_notes import FeedingNotification + +from AHC_app.medical_notes.models.type_feeding_notes import FeedingNotification register = template.Library() diff --git a/AHC_app/medical_notes/urls.py b/AHC_app/medical_notes/urls.py index dea5590..0900afc 100644 --- a/AHC_app/medical_notes/urls.py +++ b/AHC_app/medical_notes/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from medical_notes.views import type_basic_note as notes_views -from medical_notes.views import type_feeding_notes as feeding_views -from medical_notes.views import type_measurement_notes as measurement_views + +from AHC_app.medical_notes.views import type_basic_note as notes_views +from AHC_app.medical_notes.views import type_feeding_notes as feeding_views +from AHC_app.medical_notes.views import type_measurement_notes as measurement_views urlpatterns = [ path("/create/", notes_views.CreateNoteFormView.as_view(), name="note_create"), diff --git a/AHC_app/medical_notes/views/type_basic_note.py b/AHC_app/medical_notes/views/type_basic_note.py index 7748361..70a3adb 100644 --- a/AHC_app/medical_notes/views/type_basic_note.py +++ b/AHC_app/medical_notes/views/type_basic_note.py @@ -1,4 +1,3 @@ -from animals.models import Animal as AnimalProfile from django.conf import settings from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin @@ -12,13 +11,18 @@ from django.views.generic import View from django.views.generic.edit import DeleteView, FormView, UpdateView from django.views.generic.list import ListView -from medical_notes.forms.type_basic_note import ( + +from AHC_app.animals.models import Animal as AnimalProfile +from AHC_app.medical_notes.forms.type_basic_note import ( MedicalRecordEditForm, MedicalRecordEditRelatedAnimalsForm, MedicalRecordForm, UploadAppendixForm, ) -from medical_notes.models.type_basic_note import MedicalRecord, MedicalRecordAttachment +from AHC_app.medical_notes.models.type_basic_note import ( + MedicalRecord, + MedicalRecordAttachment, +) # UploadAppendixFormSet = formset_factory(UploadAppendixForm, extra=0) diff --git a/AHC_app/medical_notes/views/type_feeding_notes.py b/AHC_app/medical_notes/views/type_feeding_notes.py index 7fe7c76..84e10ec 100644 --- a/AHC_app/medical_notes/views/type_feeding_notes.py +++ b/AHC_app/medical_notes/views/type_feeding_notes.py @@ -1,4 +1,3 @@ -from animals.models import Animal as AnimalProfile from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.http import HttpResponseRedirect @@ -6,12 +5,17 @@ from django.urls import reverse_lazy from django.views.generic.edit import FormView, UpdateView from django.views.generic.list import ListView -from medical_notes.forms.type_feeding_notes import ( + +from AHC_app.animals.models import Animal as AnimalProfile +from AHC_app.medical_notes.forms.type_feeding_notes import ( DietRecordForm, NotificationRecordForm, ) -from medical_notes.models.type_basic_note import MedicalRecord -from medical_notes.models.type_feeding_notes import EmailNotification, FeedingNote +from AHC_app.medical_notes.models.type_basic_note import MedicalRecord +from AHC_app.medical_notes.models.type_feeding_notes import ( + EmailNotification, + FeedingNote, +) class DietRecordCreateView(LoginRequiredMixin, UserPassesTestMixin, FormView): diff --git a/AHC_app/medical_notes/views/type_measurement_notes.py b/AHC_app/medical_notes/views/type_measurement_notes.py index b1b93f4..8dd94bc 100644 --- a/AHC_app/medical_notes/views/type_measurement_notes.py +++ b/AHC_app/medical_notes/views/type_measurement_notes.py @@ -1,9 +1,10 @@ -from animals.models import Animal as AnimalProfile from django.shortcuts import get_object_or_404, redirect, reverse from django.views.generic.edit import FormView -from medical_notes.forms.type_measurement_notes import BiometricRecordForm -from medical_notes.models.type_basic_note import MedicalRecord -from medical_notes.models.type_measurement_notes import ( + +from AHC_app.animals.models import Animal as AnimalProfile +from AHC_app.medical_notes.forms.type_measurement_notes import BiometricRecordForm +from AHC_app.medical_notes.models.type_basic_note import MedicalRecord +from AHC_app.medical_notes.models.type_measurement_notes import ( BiometricCustomRecords, BiometricHeightRecords, BiometricRecord, @@ -33,9 +34,7 @@ def form_valid(self, form): if record_type == "weight": weight = form.cleaned_data["weight"] unit = form.cleaned_data["weight_unit_to_present"] - weight_record = BiometricWeightRecords.objects.create( - weight=weight, weight_unit_to_present=unit - ) + weight_record = BiometricWeightRecords.objects.create(weight=weight, weight_unit_to_present=unit) biometric_record = BiometricRecord.objects.create( animal=animal, related_note=related_note, @@ -44,9 +43,7 @@ def form_valid(self, form): elif record_type == "height": height = form.cleaned_data["height"] unit = form.cleaned_data["height_unit_to_present"] - height_record = BiometricHeightRecords.objects.create( - height=height, height_unit_to_present=unit - ) + height_record = BiometricHeightRecords.objects.create(height=height, height_unit_to_present=unit) biometric_record = BiometricRecord.objects.create( animal=animal, related_note=related_note, diff --git a/AHC_app/users/admin.py b/AHC_app/users/admin.py index 308a0b3..2fbb56e 100644 --- a/AHC_app/users/admin.py +++ b/AHC_app/users/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Profile +from AHC_app.users.models import Profile admin.site.register(Profile) diff --git a/AHC_app/users/forms.py b/AHC_app/users/forms.py index fbb4264..9a1f1bd 100644 --- a/AHC_app/users/forms.py +++ b/AHC_app/users/forms.py @@ -1,7 +1,7 @@ from django import forms from django.contrib.auth.forms import User, UserCreationForm -from .models import Profile +from AHC_app.users.models import Profile class UserRegisterForm(UserCreationForm): diff --git a/AHC_app/users/models.py b/AHC_app/users/models.py index 9a67048..ccd9d7b 100644 --- a/AHC_app/users/models.py +++ b/AHC_app/users/models.py @@ -1,8 +1,9 @@ from django.contrib.auth.models import User from django.db import models -from homepage.models import Privilege, ProfileBackground from PIL import Image +from AHC_app.homepage.models import Privilege, ProfileBackground + class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) diff --git a/AHC_app/users/signals.py b/AHC_app/users/signals.py index 75fd7e6..8ac0972 100644 --- a/AHC_app/users/signals.py +++ b/AHC_app/users/signals.py @@ -1,9 +1,9 @@ from django.contrib.auth.models import User from django.db.models.signals import post_save, pre_save from django.dispatch import receiver -from homepage.models import Privilege, ProfileBackground -from .models import Profile +from AHC_app.homepage.models import Privilege, ProfileBackground +from AHC_app.users.models import Profile @receiver(pre_save, sender=Profile) @@ -16,18 +16,14 @@ def create_basic_privilege(sender, instance, **kwargs): @receiver(pre_save, sender=Profile) def create_background(sender, instance, **kwargs): if not instance.profile_background: - background, _ = ProfileBackground.objects.get_or_create( - title="Default Background" - ) + background, _ = ProfileBackground.objects.get_or_create(title="Default Background") instance.profile_background = background @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): if created: - background, _ = ProfileBackground.objects.get_or_create( - title="Default Background" - ) + background, _ = ProfileBackground.objects.get_or_create(title="Default Background") Profile.objects.create(user=instance) diff --git a/AHC_app/users/urls.py b/AHC_app/users/urls.py index cd9109d..11427c9 100644 --- a/AHC_app/users/urls.py +++ b/AHC_app/users/urls.py @@ -7,17 +7,37 @@ ) from django.urls import path -from . import views as user_views +from AHC_app.users import views as user_views urlpatterns = [ path("", auth_views.LoginView.as_view(template_name="users/login.html"), name="login"), path("login/", auth_views.LoginView.as_view(template_name="users/login.html"), name="login"), path("register/", user_views.UserRegisterView.as_view(), name="register"), - path("login_success/", auth_views.LoginView.as_view(template_name="users/login_success.html"), name="login_success"), + path( + "login_success/", auth_views.LoginView.as_view(template_name="users/login_success.html"), name="login_success" + ), path("logout/", auth_views.LogoutView.as_view(template_name="users/logout.html"), name="logout"), path("profile/", user_views.UserProfileView.as_view(), name="profile"), - path("password-reset/", PasswordResetView.as_view(template_name="users/password_reset.html", html_email_template_name="users/password_reset_email.html"), name="password-reset"), - path("password-reset/done/", PasswordResetDoneView.as_view(template_name="users/password_reset_done.html"), name="password_reset_done"), - path("password-reset-confirm///", PasswordResetConfirmView.as_view(template_name="users/password_reset_confirm.html"), name="password_reset_confirm"), - path("password-reset-complete/", PasswordResetCompleteView.as_view(template_name="users/password_reset_complete.html"), name="password_reset_complete"), + path( + "password-reset/", + PasswordResetView.as_view( + template_name="users/password_reset.html", html_email_template_name="users/password_reset_email.html" + ), + name="password-reset", + ), + path( + "password-reset/done/", + PasswordResetDoneView.as_view(template_name="users/password_reset_done.html"), + name="password_reset_done", + ), + path( + "password-reset-confirm///", + PasswordResetConfirmView.as_view(template_name="users/password_reset_confirm.html"), + name="password_reset_confirm", + ), + path( + "password-reset-complete/", + PasswordResetCompleteView.as_view(template_name="users/password_reset_complete.html"), + name="password_reset_complete", + ), ] diff --git a/AHC_app/users/views.py b/AHC_app/users/views.py index 9df47c7..698c31c 100644 --- a/AHC_app/users/views.py +++ b/AHC_app/users/views.py @@ -1,10 +1,10 @@ from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse_lazy -from django.views.generic import CreateView, FormView, UpdateView +from django.views.generic import CreateView, UpdateView -from .forms import ProfileUpdateForm, UserRegisterForm, UserUpdateForm -from .models import Profile +from AHC_app.users.forms import ProfileUpdateForm, UserRegisterForm, UserUpdateForm +from AHC_app.users.models import Profile class UserRegisterView(CreateView): From 2b095ff343bb271660ee2cdbf9f21a867f06c60d Mon Sep 17 00:00:00 2001 From: Cybernetic-Ransomware <71835339+Cybernetic-Ransomware@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:27:11 +0200 Subject: [PATCH 2/4] Deploy Queue container on Python 3.11 (last one supported by Celery) --- AHC_app/Dockerfile-queue | 10 ++++++++++ AHC_app/{Dockerfile => Dockerfile-web} | 0 AHC_app/docker-compose.yml | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 AHC_app/Dockerfile-queue rename AHC_app/{Dockerfile => Dockerfile-web} (100%) diff --git a/AHC_app/Dockerfile-queue b/AHC_app/Dockerfile-queue new file mode 100644 index 0000000..58a77d5 --- /dev/null +++ b/AHC_app/Dockerfile-queue @@ -0,0 +1,10 @@ +FROM python:3.11 +LABEL authors="AM" +WORKDIR /app +COPY Pipfile Pipfile.lock ./ + +RUN python -m pip install --upgrade pip && \ + pip install --no-cache-dir pipenv && \ + pipenv install --dev --system --deploy + +COPY . . diff --git a/AHC_app/Dockerfile b/AHC_app/Dockerfile-web similarity index 100% rename from AHC_app/Dockerfile rename to AHC_app/Dockerfile-web diff --git a/AHC_app/docker-compose.yml b/AHC_app/docker-compose.yml index eb0a894..fdd7181 100644 --- a/AHC_app/docker-compose.yml +++ b/AHC_app/docker-compose.yml @@ -1,7 +1,9 @@ version: "3.9" services: web: - build: . + build: + context: . + dockerfile: Dockerfile-web image: ahc_app-web:latest ports: - "8000:8000" @@ -71,7 +73,9 @@ services: restart: always queue: - build: . + build: + context: . + dockerfile: Dockerfile-queue command: celery -A AHC_app.celery_notifications.config:celery_obj worker -l info depends_on: redis: From 107adab22d8982840e51d6db1bf44dfd9016ef54 Mon Sep 17 00:00:00 2001 From: Cybernetic-Ransomware <71835339+Cybernetic-Ransomware@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:28:23 +0200 Subject: [PATCH 3/4] Fix imports due to change in PYTHONPATH --- .../AHC_app/celery_notifications/config.py | 4 ++-- AHC_app/animals/forms.py | 3 +-- .../mixins/animal_owner_permissions.py | 3 +-- AHC_app/animals/models.py | 3 +-- AHC_app/animals/signals.py | 5 ++--- AHC_app/animals/urls.py | 5 ++--- AHC_app/animals/utils_owner/forms.py | 5 ++--- AHC_app/animals/utils_owner/views.py | 19 +++++++++---------- AHC_app/animals/views.py | 7 +++---- AHC_app/homepage/admin.py | 3 +-- .../management/commands/sync_cronjobs.py | 3 +-- AHC_app/homepage/models.py | 3 +-- AHC_app/homepage/tests/test_homepage.py | 5 ++--- AHC_app/homepage/urls.py | 3 +-- AHC_app/homepage/views.py | 5 ++--- .../medical_notes/forms/type_basic_note.py | 5 +---- .../medical_notes/forms/type_feeding_notes.py | 6 +----- .../medical_notes/models/type_basic_note.py | 5 ++--- .../signals/type_feeding_notes.py | 5 ++--- .../signals/type_measurement_notes.py | 7 +++---- .../templatetags/custom_file_name.py | 3 +-- AHC_app/medical_notes/urls.py | 7 +++---- .../medical_notes/views/type_basic_note.py | 10 +++------- .../medical_notes/views/type_feeding_notes.py | 12 ++++-------- .../views/type_measurement_notes.py | 9 ++++----- AHC_app/users/admin.py | 3 +-- AHC_app/users/forms.py | 3 +-- AHC_app/users/models.py | 3 +-- AHC_app/users/signals.py | 5 ++--- AHC_app/users/urls.py | 3 +-- AHC_app/users/views.py | 5 ++--- 31 files changed, 63 insertions(+), 104 deletions(-) diff --git a/AHC_app/AHC_app/celery_notifications/config.py b/AHC_app/AHC_app/celery_notifications/config.py index 9db2eea..7a3c94e 100644 --- a/AHC_app/AHC_app/celery_notifications/config.py +++ b/AHC_app/AHC_app/celery_notifications/config.py @@ -4,8 +4,8 @@ from celery.utils.log import get_task_logger from django.conf import settings -from AHC_app.AHC_app.celery_notifications.utils.discord_utils import send_via_discord -from AHC_app.AHC_app.celery_notifications.utils.sending_utils import ( +from AHC_app.celery_notifications.utils.discord_utils import send_via_discord +from AHC_app.celery_notifications.utils.sending_utils import ( send_via_email, # , send_via_sms, send_via_discord ) diff --git a/AHC_app/animals/forms.py b/AHC_app/animals/forms.py index ac91ac5..fa3d045 100644 --- a/AHC_app/animals/forms.py +++ b/AHC_app/animals/forms.py @@ -1,9 +1,8 @@ +from animals.models import Animal from django import forms from django.core.validators import MaxLengthValidator, MinLengthValidator from django.db.models import Q -from AHC_app.animals.models import Animal - class AnimalRegisterForm(forms.ModelForm): class Meta: diff --git a/AHC_app/animals/mixins/animal_owner_permissions.py b/AHC_app/animals/mixins/animal_owner_permissions.py index 741c94b..378f8c0 100644 --- a/AHC_app/animals/mixins/animal_owner_permissions.py +++ b/AHC_app/animals/mixins/animal_owner_permissions.py @@ -1,7 +1,6 @@ +from animals.models import Animal from django.contrib.auth.mixins import UserPassesTestMixin -from AHC_app.animals.models import Animal - class UserPassesOwnershipTestMixin(UserPassesTestMixin): def test_func(self): diff --git a/AHC_app/animals/models.py b/AHC_app/animals/models.py index 95c24b7..d64a8d1 100644 --- a/AHC_app/animals/models.py +++ b/AHC_app/animals/models.py @@ -1,8 +1,7 @@ import uuid from django.db import models - -from AHC_app.users.models import Profile as UserProfile +from users.models import Profile as UserProfile class Animal(models.Model): diff --git a/AHC_app/animals/signals.py b/AHC_app/animals/signals.py index 256cd10..05ebd4f 100644 --- a/AHC_app/animals/signals.py +++ b/AHC_app/animals/signals.py @@ -1,10 +1,9 @@ import os +from animals.models import Animal from django.db.models.signals import post_delete, post_save, pre_delete from django.dispatch import receiver - -from AHC_app.animals.models import Animal -from AHC_app.users.models import Profile +from users.models import Profile @receiver(post_save, sender=Animal) diff --git a/AHC_app/animals/urls.py b/AHC_app/animals/urls.py index 4d68d3d..f741254 100644 --- a/AHC_app/animals/urls.py +++ b/AHC_app/animals/urls.py @@ -1,8 +1,7 @@ +from animals import views as animal_views +from animals.utils_owner import views as animal_owner_views from django.urls import path -from AHC_app.animals import views as animal_views -from AHC_app.animals.utils_owner import views as animal_owner_views - urlpatterns = [ path("create/", animal_views.CreateAnimalView.as_view(), name="animal_create"), path("/delete/", animal_owner_views.AnimalDeleteView.as_view(), name="animal_delete"), diff --git a/AHC_app/animals/utils_owner/forms.py b/AHC_app/animals/utils_owner/forms.py index dd302eb..868e015 100644 --- a/AHC_app/animals/utils_owner/forms.py +++ b/AHC_app/animals/utils_owner/forms.py @@ -1,10 +1,9 @@ from datetime import date +from animals.models import Animal from django import forms from PIL import Image - -from AHC_app.animals.models import Animal -from AHC_app.users.models import Profile +from users.models import Profile class ImageUploadForm(forms.ModelForm): diff --git a/AHC_app/animals/utils_owner/views.py b/AHC_app/animals/utils_owner/views.py index 26481ad..963d817 100644 --- a/AHC_app/animals/utils_owner/views.py +++ b/AHC_app/animals/utils_owner/views.py @@ -1,19 +1,18 @@ -from django.contrib.auth.mixins import LoginRequiredMixin -from django.shortcuts import get_object_or_404, redirect -from django.urls import reverse, reverse_lazy -from django.views.generic import DeleteView -from django.views.generic.edit import FormView -from PIL import Image - -from AHC_app.animals.mixins.animal_owner_permissions import UserPassesOwnershipTestMixin -from AHC_app.animals.models import Animal -from AHC_app.animals.utils_owner.forms import ( +from animals.mixins.animal_owner_permissions import UserPassesOwnershipTestMixin +from animals.models import Animal +from animals.utils_owner.forms import ( ChangeBirthdayForm, ChangeFirstContactForm, ChangeOwnerForm, ImageUploadForm, ManageKeepersForm, ) +from django.contrib.auth.mixins import LoginRequiredMixin +from django.shortcuts import get_object_or_404, redirect +from django.urls import reverse, reverse_lazy +from django.views.generic import DeleteView +from django.views.generic.edit import FormView +from PIL import Image class AnimalDeleteView(LoginRequiredMixin, UserPassesOwnershipTestMixin, DeleteView): diff --git a/AHC_app/animals/views.py b/AHC_app/animals/views.py index a21d815..84f1c0b 100644 --- a/AHC_app/animals/views.py +++ b/AHC_app/animals/views.py @@ -1,3 +1,5 @@ +from animals.forms import AnimalRegisterForm, PinAnimalForm +from animals.models import Animal from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.db.models import Q from django.http import JsonResponse @@ -6,10 +8,7 @@ from django.views.generic import TemplateView, View from django.views.generic.detail import DetailView from django.views.generic.edit import FormView - -from AHC_app.animals.forms import AnimalRegisterForm, PinAnimalForm -from AHC_app.animals.models import Animal -from AHC_app.medical_notes.models.type_basic_note import MedicalRecord +from medical_notes.models.type_basic_note import MedicalRecord # from users.models import Profile as UserProfile diff --git a/AHC_app/homepage/admin.py b/AHC_app/homepage/admin.py index 8ae0ccc..23fc0d8 100644 --- a/AHC_app/homepage/admin.py +++ b/AHC_app/homepage/admin.py @@ -1,6 +1,5 @@ from django.contrib import admin - -from AHC_app.homepage.models import AnimalTitle, CronJob +from homepage.models import AnimalTitle, CronJob admin.site.register(AnimalTitle) diff --git a/AHC_app/homepage/management/commands/sync_cronjobs.py b/AHC_app/homepage/management/commands/sync_cronjobs.py index 8935319..80ccaa6 100644 --- a/AHC_app/homepage/management/commands/sync_cronjobs.py +++ b/AHC_app/homepage/management/commands/sync_cronjobs.py @@ -1,8 +1,7 @@ import subprocess from django.core.management.base import BaseCommand - -from AHC_app.homepage.models import CronJob +from homepage.models import CronJob class Command(BaseCommand): diff --git a/AHC_app/homepage/models.py b/AHC_app/homepage/models.py index f872255..fab7fc2 100644 --- a/AHC_app/homepage/models.py +++ b/AHC_app/homepage/models.py @@ -1,8 +1,7 @@ from django.contrib.auth.models import User from django.db import models from django.urls import reverse - -from AHC_app.homepage.utils import ImageGenerator +from homepage.utils import ImageGenerator class Privilege(models.Model): diff --git a/AHC_app/homepage/tests/test_homepage.py b/AHC_app/homepage/tests/test_homepage.py index a6af1b9..fe3ad54 100644 --- a/AHC_app/homepage/tests/test_homepage.py +++ b/AHC_app/homepage/tests/test_homepage.py @@ -2,8 +2,7 @@ from django.contrib.auth.models import User from django.test import Client, TestCase - -from AHC_app.homepage.models import AnimalTitle +from homepage.models import AnimalTitle client = Client() @@ -40,7 +39,7 @@ def test_should_return_status_code_200_when_view_is_get_called(self): actual_status_code = resp.status_code # assert actual_status_code == expected_status_code - self.assertEquals(expected_status_code, actual_status_code) + self.assertEqual(expected_status_code, actual_status_code) def test_should_return_valid_render_template_name_when_view_is_get_called(self): expected_template_name = "homepage/homepage.html" diff --git a/AHC_app/homepage/urls.py b/AHC_app/homepage/urls.py index 604d2b8..6f65fb3 100644 --- a/AHC_app/homepage/urls.py +++ b/AHC_app/homepage/urls.py @@ -1,6 +1,5 @@ from django.urls import path - -from AHC_app.homepage.views import HomepageView +from homepage.views import HomepageView urlpatterns = [ path("", HomepageView.as_view(), name="Homepage"), diff --git a/AHC_app/homepage/views.py b/AHC_app/homepage/views.py index 3fe3dbc..1a51f30 100644 --- a/AHC_app/homepage/views.py +++ b/AHC_app/homepage/views.py @@ -1,8 +1,7 @@ +from animals.models import Animal from django.db.models import Q from django.views.generic import TemplateView - -from AHC_app.animals.models import Animal -from AHC_app.users.models import Profile as UserProfile +from users.models import Profile as UserProfile class HomepageView(TemplateView): diff --git a/AHC_app/medical_notes/forms/type_basic_note.py b/AHC_app/medical_notes/forms/type_basic_note.py index cc2d342..8263457 100644 --- a/AHC_app/medical_notes/forms/type_basic_note.py +++ b/AHC_app/medical_notes/forms/type_basic_note.py @@ -1,10 +1,7 @@ from django import forms # from animals.models import Animal as AnimalProfile -from AHC_app.medical_notes.models.type_basic_note import ( - MedicalRecord, - MedicalRecordAttachment, -) +from medical_notes.models.type_basic_note import MedicalRecord, MedicalRecordAttachment # from django.core.validators import MaxLengthValidator, MinLengthValidator # from django.db.models import Q diff --git a/AHC_app/medical_notes/forms/type_feeding_notes.py b/AHC_app/medical_notes/forms/type_feeding_notes.py index 90197a3..3e4fb4e 100644 --- a/AHC_app/medical_notes/forms/type_feeding_notes.py +++ b/AHC_app/medical_notes/forms/type_feeding_notes.py @@ -1,12 +1,8 @@ from django import forms from django.conf import settings +from medical_notes.models.type_feeding_notes import EmailNotification, FeedingNote from timezone_field import TimeZoneFormField -from AHC_app.medical_notes.models.type_feeding_notes import ( - EmailNotification, - FeedingNote, -) - class DietRecordForm(forms.ModelForm): class Meta: diff --git a/AHC_app/medical_notes/models/type_basic_note.py b/AHC_app/medical_notes/models/type_basic_note.py index 9fd581d..b5ce3d4 100644 --- a/AHC_app/medical_notes/models/type_basic_note.py +++ b/AHC_app/medical_notes/models/type_basic_note.py @@ -1,11 +1,10 @@ import uuid +from animals.models import Animal from django.db import models from taggit.managers import TaggableManager from taggit.models import GenericUUIDTaggedItemBase, TaggedItemBase - -from AHC_app.animals.models import Animal -from AHC_app.users.models import Profile as UserProfile +from users.models import Profile as UserProfile class UUIDTaggedItem(GenericUUIDTaggedItemBase, TaggedItemBase): diff --git a/AHC_app/medical_notes/signals/type_feeding_notes.py b/AHC_app/medical_notes/signals/type_feeding_notes.py index 02f378e..ce07d43 100644 --- a/AHC_app/medical_notes/signals/type_feeding_notes.py +++ b/AHC_app/medical_notes/signals/type_feeding_notes.py @@ -1,9 +1,8 @@ from django.db import transaction from django.db.models.signals import post_save from django.dispatch import receiver - -from AHC_app.medical_notes.models.type_feeding_notes import FeedingNote -from AHC_app.users.models import Profile as UserProfile +from medical_notes.models.type_feeding_notes import FeedingNote +from users.models import Profile as UserProfile @receiver(post_save, sender=FeedingNote) diff --git a/AHC_app/medical_notes/signals/type_measurement_notes.py b/AHC_app/medical_notes/signals/type_measurement_notes.py index 6c57a9c..6e7cb9e 100644 --- a/AHC_app/medical_notes/signals/type_measurement_notes.py +++ b/AHC_app/medical_notes/signals/type_measurement_notes.py @@ -2,10 +2,9 @@ from django.db.models import Q from django.db.models.signals import post_save, pre_save from django.dispatch import receiver - -from AHC_app.medical_notes.models.type_basic_note import MedicalRecord -from AHC_app.medical_notes.models.type_measurement_notes import BiometricRecord -from AHC_app.users.models import Profile as UserProfile +from medical_notes.models.type_basic_note import MedicalRecord +from medical_notes.models.type_measurement_notes import BiometricRecord +from users.models import Profile as UserProfile @receiver(pre_save, sender=BiometricRecord) diff --git a/AHC_app/medical_notes/templatetags/custom_file_name.py b/AHC_app/medical_notes/templatetags/custom_file_name.py index 316e3bb..82d6968 100644 --- a/AHC_app/medical_notes/templatetags/custom_file_name.py +++ b/AHC_app/medical_notes/templatetags/custom_file_name.py @@ -1,6 +1,5 @@ from django import template - -from AHC_app.medical_notes.models.type_feeding_notes import FeedingNotification +from medical_notes.models.type_feeding_notes import FeedingNotification register = template.Library() diff --git a/AHC_app/medical_notes/urls.py b/AHC_app/medical_notes/urls.py index 0900afc..dea5590 100644 --- a/AHC_app/medical_notes/urls.py +++ b/AHC_app/medical_notes/urls.py @@ -1,8 +1,7 @@ from django.urls import path - -from AHC_app.medical_notes.views import type_basic_note as notes_views -from AHC_app.medical_notes.views import type_feeding_notes as feeding_views -from AHC_app.medical_notes.views import type_measurement_notes as measurement_views +from medical_notes.views import type_basic_note as notes_views +from medical_notes.views import type_feeding_notes as feeding_views +from medical_notes.views import type_measurement_notes as measurement_views urlpatterns = [ path("/create/", notes_views.CreateNoteFormView.as_view(), name="note_create"), diff --git a/AHC_app/medical_notes/views/type_basic_note.py b/AHC_app/medical_notes/views/type_basic_note.py index 70a3adb..7748361 100644 --- a/AHC_app/medical_notes/views/type_basic_note.py +++ b/AHC_app/medical_notes/views/type_basic_note.py @@ -1,3 +1,4 @@ +from animals.models import Animal as AnimalProfile from django.conf import settings from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin @@ -11,18 +12,13 @@ from django.views.generic import View from django.views.generic.edit import DeleteView, FormView, UpdateView from django.views.generic.list import ListView - -from AHC_app.animals.models import Animal as AnimalProfile -from AHC_app.medical_notes.forms.type_basic_note import ( +from medical_notes.forms.type_basic_note import ( MedicalRecordEditForm, MedicalRecordEditRelatedAnimalsForm, MedicalRecordForm, UploadAppendixForm, ) -from AHC_app.medical_notes.models.type_basic_note import ( - MedicalRecord, - MedicalRecordAttachment, -) +from medical_notes.models.type_basic_note import MedicalRecord, MedicalRecordAttachment # UploadAppendixFormSet = formset_factory(UploadAppendixForm, extra=0) diff --git a/AHC_app/medical_notes/views/type_feeding_notes.py b/AHC_app/medical_notes/views/type_feeding_notes.py index 84e10ec..7fe7c76 100644 --- a/AHC_app/medical_notes/views/type_feeding_notes.py +++ b/AHC_app/medical_notes/views/type_feeding_notes.py @@ -1,3 +1,4 @@ +from animals.models import Animal as AnimalProfile from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.http import HttpResponseRedirect @@ -5,17 +6,12 @@ from django.urls import reverse_lazy from django.views.generic.edit import FormView, UpdateView from django.views.generic.list import ListView - -from AHC_app.animals.models import Animal as AnimalProfile -from AHC_app.medical_notes.forms.type_feeding_notes import ( +from medical_notes.forms.type_feeding_notes import ( DietRecordForm, NotificationRecordForm, ) -from AHC_app.medical_notes.models.type_basic_note import MedicalRecord -from AHC_app.medical_notes.models.type_feeding_notes import ( - EmailNotification, - FeedingNote, -) +from medical_notes.models.type_basic_note import MedicalRecord +from medical_notes.models.type_feeding_notes import EmailNotification, FeedingNote class DietRecordCreateView(LoginRequiredMixin, UserPassesTestMixin, FormView): diff --git a/AHC_app/medical_notes/views/type_measurement_notes.py b/AHC_app/medical_notes/views/type_measurement_notes.py index 8dd94bc..e4c0a3b 100644 --- a/AHC_app/medical_notes/views/type_measurement_notes.py +++ b/AHC_app/medical_notes/views/type_measurement_notes.py @@ -1,10 +1,9 @@ +from animals.models import Animal as AnimalProfile from django.shortcuts import get_object_or_404, redirect, reverse from django.views.generic.edit import FormView - -from AHC_app.animals.models import Animal as AnimalProfile -from AHC_app.medical_notes.forms.type_measurement_notes import BiometricRecordForm -from AHC_app.medical_notes.models.type_basic_note import MedicalRecord -from AHC_app.medical_notes.models.type_measurement_notes import ( +from medical_notes.forms.type_measurement_notes import BiometricRecordForm +from medical_notes.models.type_basic_note import MedicalRecord +from medical_notes.models.type_measurement_notes import ( BiometricCustomRecords, BiometricHeightRecords, BiometricRecord, diff --git a/AHC_app/users/admin.py b/AHC_app/users/admin.py index 2fbb56e..ed54a24 100644 --- a/AHC_app/users/admin.py +++ b/AHC_app/users/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - -from AHC_app.users.models import Profile +from users.models import Profile admin.site.register(Profile) diff --git a/AHC_app/users/forms.py b/AHC_app/users/forms.py index 9a1f1bd..37c2b8d 100644 --- a/AHC_app/users/forms.py +++ b/AHC_app/users/forms.py @@ -1,7 +1,6 @@ from django import forms from django.contrib.auth.forms import User, UserCreationForm - -from AHC_app.users.models import Profile +from users.models import Profile class UserRegisterForm(UserCreationForm): diff --git a/AHC_app/users/models.py b/AHC_app/users/models.py index ccd9d7b..9a67048 100644 --- a/AHC_app/users/models.py +++ b/AHC_app/users/models.py @@ -1,9 +1,8 @@ from django.contrib.auth.models import User from django.db import models +from homepage.models import Privilege, ProfileBackground from PIL import Image -from AHC_app.homepage.models import Privilege, ProfileBackground - class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) diff --git a/AHC_app/users/signals.py b/AHC_app/users/signals.py index 8ac0972..6821573 100644 --- a/AHC_app/users/signals.py +++ b/AHC_app/users/signals.py @@ -1,9 +1,8 @@ from django.contrib.auth.models import User from django.db.models.signals import post_save, pre_save from django.dispatch import receiver - -from AHC_app.homepage.models import Privilege, ProfileBackground -from AHC_app.users.models import Profile +from homepage.models import Privilege, ProfileBackground +from users.models import Profile @receiver(pre_save, sender=Profile) diff --git a/AHC_app/users/urls.py b/AHC_app/users/urls.py index 11427c9..b0a23c4 100644 --- a/AHC_app/users/urls.py +++ b/AHC_app/users/urls.py @@ -6,8 +6,7 @@ PasswordResetView, ) from django.urls import path - -from AHC_app.users import views as user_views +from users import views as user_views urlpatterns = [ path("", auth_views.LoginView.as_view(template_name="users/login.html"), name="login"), diff --git a/AHC_app/users/views.py b/AHC_app/users/views.py index 698c31c..dc39aeb 100644 --- a/AHC_app/users/views.py +++ b/AHC_app/users/views.py @@ -2,9 +2,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse_lazy from django.views.generic import CreateView, UpdateView - -from AHC_app.users.forms import ProfileUpdateForm, UserRegisterForm, UserUpdateForm -from AHC_app.users.models import Profile +from users.forms import ProfileUpdateForm, UserRegisterForm, UserUpdateForm +from users.models import Profile class UserRegisterView(CreateView): From 08274b03e8e74cb3a5bc2a95a994db47d0392991 Mon Sep 17 00:00:00 2001 From: Cybernetic-Ransomware <71835339+Cybernetic-Ransomware@users.noreply.github.com> Date: Sat, 23 May 2026 18:20:34 +0200 Subject: [PATCH 4/4] Re-enable celery worker command; fix Python version mismatch; disable Discord temporarily --- AHC_app/AHC_app/celery_notifications/config.py | 13 ++++++------- .../celery_notifications/utils/discord_utils.py | 3 ++- AHC_app/Dockerfile-queue | 2 +- kubernetes/queue/celery/deployment.yaml | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/AHC_app/AHC_app/celery_notifications/config.py b/AHC_app/AHC_app/celery_notifications/config.py index 7a3c94e..bcfa1c6 100644 --- a/AHC_app/AHC_app/celery_notifications/config.py +++ b/AHC_app/AHC_app/celery_notifications/config.py @@ -4,10 +4,8 @@ from celery.utils.log import get_task_logger from django.conf import settings -from AHC_app.celery_notifications.utils.discord_utils import send_via_discord -from AHC_app.celery_notifications.utils.sending_utils import ( - send_via_email, # , send_via_sms, send_via_discord -) +# from AHC_app.celery_notifications.utils.discord_utils import send_via_discord +from AHC_app.celery_notifications.utils.sending_utils import send_via_email logger = get_task_logger(__name__) @@ -44,6 +42,7 @@ def send_sms_notifications(**kwargs): @shared_task(bind=True) def send_discord_notifications(self, *args, **kwargs): - user_id = kwargs.get("user_id") - user_message = kwargs.get("user_message") - send_via_discord(user_id, user_message) + # user_id = kwargs.get("user_id") + # user_message = kwargs.get("user_message") + # send_via_discord(user_id, user_message) + pass diff --git a/AHC_app/AHC_app/celery_notifications/utils/discord_utils.py b/AHC_app/AHC_app/celery_notifications/utils/discord_utils.py index 7a0746d..87da4e7 100644 --- a/AHC_app/AHC_app/celery_notifications/utils/discord_utils.py +++ b/AHC_app/AHC_app/celery_notifications/utils/discord_utils.py @@ -4,7 +4,8 @@ from discord.ext import commands from django.conf import settings -TOKEN = settings.DISCORD_TOKEN +# TOKEN = settings.DISCORD_TOKEN +TOKEN = "none" def send_via_discord(user_id: int, user_message: str) -> None: diff --git a/AHC_app/Dockerfile-queue b/AHC_app/Dockerfile-queue index 58a77d5..0cc351b 100644 --- a/AHC_app/Dockerfile-queue +++ b/AHC_app/Dockerfile-queue @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM python:3.12 LABEL authors="AM" WORKDIR /app COPY Pipfile Pipfile.lock ./ diff --git a/kubernetes/queue/celery/deployment.yaml b/kubernetes/queue/celery/deployment.yaml index 7d26d36..ccfc7d9 100644 --- a/kubernetes/queue/celery/deployment.yaml +++ b/kubernetes/queue/celery/deployment.yaml @@ -27,7 +27,6 @@ spec: image: ahc_app-queue:latest imagePullPolicy: Never command: [ "celery", "-A", "AHC_app.celery_notifications.config:celery_obj", "worker", "-l", "info"] -# command: [ "sleep", "infinity" ] # debug env: - name: PYTHONUNBUFFERED value: "1"