From 0e1ddbcf1aa993f84309b72847a07bb15685ff95 Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Tue, 22 Apr 2025 11:46:55 -0500 Subject: [PATCH] Updates to the main page --- schasite/forms.py | 5 + ...communitypost_communityschools_and_more.py | 290 +++++++++++++ schasite/models.py | 86 ++-- .../schasite/authenticated_base.html | 61 ++- schasite/templates/schasite/base2.html | 2 +- schasite/templates/schasite/index2.html | 40 +- .../templates/schasite/member_dashboard.html | 10 +- .../templates/schasite/member_directory.html | 2 +- schasite/templates/schasite/member_posts.html | 166 ++++++++ .../schasite/member_posts_create.html | 124 ++++++ .../schasite/member_posts_detail.html | 328 +++++++++++++++ schasite/templates/schasite/profile.html | 396 ++++++++++++++++++ schasite/urls.py | 5 + schasite/views.py | 38 +- 14 files changed, 1493 insertions(+), 60 deletions(-) create mode 100644 schasite/migrations/0010_communityparks_communitypost_communityschools_and_more.py create mode 100644 schasite/templates/schasite/member_posts_create.html create mode 100644 schasite/templates/schasite/member_posts_detail.html create mode 100644 schasite/templates/schasite/profile.html diff --git a/schasite/forms.py b/schasite/forms.py index eb626b5..978250f 100644 --- a/schasite/forms.py +++ b/schasite/forms.py @@ -2,6 +2,7 @@ from django import forms from django.forms import ModelForm from .models import ( Membership, + CommunityPost, AddressModel1, MembershipPerson, MembershipCommittee, @@ -38,6 +39,10 @@ class AddressForm(ModelForm): model = AddressModel1 fields = ["address_1", "address_2", "city", "state", "zip_code"] +class CommunityPostForm(ModelForm): + class Meta: + model = CommunityPost + fields = ['title','category','content'] class PeopleForm(ModelForm): phone_number = PhoneNumberField(required=False) diff --git a/schasite/migrations/0010_communityparks_communitypost_communityschools_and_more.py b/schasite/migrations/0010_communityparks_communitypost_communityschools_and_more.py new file mode 100644 index 0000000..54c6560 --- /dev/null +++ b/schasite/migrations/0010_communityparks_communitypost_communityschools_and_more.py @@ -0,0 +1,290 @@ +# Generated by Django 5.2 on 2025-04-21 17:42 + +import datetime +import django.db.models.deletion +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("schasite", "0009_schaofficer_alter_payments_date"), + ] + + operations = [ + migrations.CreateModel( + name="CommunityParks", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ("name", models.CharField(max_length=255)), + ("distance", models.DecimalField(decimal_places=1, max_digits=3)), + ("description", models.CharField(max_length=1024)), + ], + options={ + "abstract": False, + }, + ), + migrations.CreateModel( + name="CommunityPost", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ("title", models.CharField(max_length=255)), + ("category", models.CharField(max_length=255)), + ("content", models.CharField(max_length=8192)), + ("likes", models.IntegerField(default=0)), + ], + options={ + "abstract": False, + }, + ), + migrations.CreateModel( + name="CommunitySchools", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ("name", models.CharField(max_length=255)), + ("name_school_url", models.URLField(max_length=256)), + ("rating_url", models.URLField(max_length=256)), + ("rating", models.DecimalField(decimal_places=2, max_digits=5)), + ("distance", models.DecimalField(decimal_places=1, max_digits=3)), + ("principal", models.CharField(max_length=255)), + ("grades", models.CharField(max_length=255)), + ], + options={ + "abstract": False, + }, + ), + migrations.CreateModel( + name="CommunityShoppingAndDining", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ("name", models.CharField(max_length=255)), + ("distance", models.DecimalField(decimal_places=1, max_digits=3)), + ("description", models.CharField(max_length=1024)), + ], + options={ + "abstract": False, + }, + ), + migrations.AddField( + model_name="addressmodel1", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="addressmodel1", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="calendarevent", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="calendarevent", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="calendareventaddressmodel", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="calendareventaddressmodel", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membership", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membership", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipcommittee", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipcommittee", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipperson", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipperson", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipservices", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="membershipservices", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="payments", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="payments", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="schaofficer", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="schaofficer", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="usefullinks", + name="created", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AddField( + model_name="usefullinks", + name="last_modified", + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AlterField( + model_name="payments", + name="date", + field=models.DateField( + default=datetime.datetime( + 2025, 4, 21, 17, 42, 47, 893058, tzinfo=datetime.timezone.utc + ) + ), + ), + migrations.CreateModel( + name="CommunityComment", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ("content", models.CharField(max_length=8192)), + ("likes", models.IntegerField(default=0)), + ( + "post", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="schasite.communitypost", + ), + ), + ], + options={ + "abstract": False, + }, + ), + migrations.CreateModel( + name="CommunityPostReports", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(default=django.utils.timezone.now)), + ( + "last_modified", + models.DateTimeField(default=django.utils.timezone.now), + ), + ( + "post", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="schasite.communitypost", + ), + ), + ], + options={ + "abstract": False, + }, + ), + ] diff --git a/schasite/models.py b/schasite/models.py index d2c4d43..f7de061 100644 --- a/schasite/models.py +++ b/schasite/models.py @@ -3,14 +3,29 @@ from phonenumber_field.modelfields import PhoneNumberField import datetime from django.utils import timezone +class TimeInfoBase(models.Model): + + created = models.DateTimeField(default=timezone.now) + last_modified = models.DateTimeField(default=timezone.now) + + class Meta: + abstract = True + + def save(self, *args, **kwargs): + if not kwargs.pop("skip_last_modified", False) and not hasattr(self, "skip_last_modified"): + self.last_modified = timezone.now() + if kwargs.get("update_fields") is not None: + kwargs["update_fields"] = list({*kwargs["update_fields"], "last_modified"}) + + super().save(*args, **kwargs) # Create your models here. -class UsefulLinks(models.Model): +class UsefulLinks(TimeInfoBase): name = models.CharField(max_length=256) url = models.CharField(max_length=256) -class Membership(models.Model): +class Membership(TimeInfoBase): children = models.CharField(max_length=256, default="", blank=True, null=True) def get_address_str(self): @@ -37,7 +52,7 @@ class Membership(models.Model): return self.get_address_str() + " | " + self.get_person_1() -class AddressModel1(models.Model): +class AddressModel1(TimeInfoBase): membership = models.OneToOneField(Membership, on_delete=models.CASCADE) address_1 = models.CharField(max_length=128) address_2 = models.CharField(max_length=128, blank=True) @@ -46,7 +61,7 @@ class AddressModel1(models.Model): zip_code = models.CharField(max_length=5) -class CalendarEvent(models.Model): +class CalendarEvent(TimeInfoBase): event_name = models.CharField(max_length=256) start_date = models.DateField(blank=True, null=True) end_date = models.DateField(blank=True, null=True) @@ -75,7 +90,7 @@ class CalendarEvent(models.Model): return not self.has_date() -class CalendarEventAddressModel(models.Model): +class CalendarEventAddressModel(TimeInfoBase): calendar_event = models.OneToOneField(CalendarEvent, on_delete=models.CASCADE) address_1 = models.CharField(max_length=128) address_2 = models.CharField(max_length=128, blank=True) @@ -89,7 +104,7 @@ class CalendarEventAddressModel(models.Model): ) -class MembershipPerson(models.Model): +class MembershipPerson(TimeInfoBase): membership = models.ForeignKey( Membership, on_delete=models.CASCADE, blank=True, null=True ) @@ -102,7 +117,7 @@ class MembershipPerson(models.Model): return self.email if self.email else "No email" -class MembershipCommittee(models.Model): +class MembershipCommittee(TimeInfoBase): membership = models.OneToOneField(Membership, on_delete=models.CASCADE) block_captain = models.BooleanField(default=False, blank=True, null=True) coordinator = models.BooleanField(default=False, blank=True, null=True) @@ -119,7 +134,7 @@ class MembershipCommittee(models.Model): no_preference = models.BooleanField(default=False, blank=True, null=True) -class MembershipServices(models.Model): +class MembershipServices(TimeInfoBase): membership = models.OneToOneField(Membership, on_delete=models.CASCADE) babysitting = models.BooleanField(default=False, blank=True, null=True) lawn_mowing = models.BooleanField(default=False, blank=True, null=True) @@ -131,7 +146,7 @@ class MembershipServices(models.Model): other_desc = models.CharField(default="", blank=True, null=True, max_length=256) -class Payments(models.Model): +class Payments(TimeInfoBase): date = models.DateField(default=timezone.now()) status = models.CharField(default="Completed", max_length=256) email = models.EmailField(blank=True, null=True) @@ -140,26 +155,45 @@ class Payments(models.Model): ) -class SCHAOfficer(models.Model): +class SCHAOfficer(TimeInfoBase): name = models.CharField(max_length=255) position = models.CharField(max_length=255) email = models.EmailField(max_length=255) -# class CommunitySchools(models.Model): -# name = models.CharField(max_length=255) -# name_school_url = models.URLField(max_length=256) -# rating_url = models.URLField(max_length=256) -# rating = models.DecimalField(max_digits=5, decimal_places=2) -# distance = models.DecimalField(max_digits=3, decimal_places=1) -# principal = models.CharField(max_length=255) -# grades = models.CharField(max_length=255) +### NOT USED YET ### -# class CommunityShoppingAndDining(models.Model): -# name = models.CharField(max_length=255) -# distance = models.DecimalField(max_digits=3, decimal_places=1) -# description = models.CharField(max_length=1024) +class CommunitySchools(TimeInfoBase): + name = models.CharField(max_length=255) + name_school_url = models.URLField(max_length=256) + rating_url = models.URLField(max_length=256) + rating = models.DecimalField(max_digits=5, decimal_places=2) + distance = models.DecimalField(max_digits=3, decimal_places=1) + principal = models.CharField(max_length=255) + grades = models.CharField(max_length=255) -# class CommunityParks(models.Model): -# name = models.CharField(max_length=255) -# distance = models.DecimalField(max_digits=3, decimal_places=1) -# description = models.CharField(max_length=1024) \ No newline at end of file +class CommunityShoppingAndDining(TimeInfoBase): + name = models.CharField(max_length=255) + distance = models.DecimalField(max_digits=3, decimal_places=1) + description = models.CharField(max_length=1024) + +class CommunityParks(TimeInfoBase): + name = models.CharField(max_length=255) + distance = models.DecimalField(max_digits=3, decimal_places=1) + description = models.CharField(max_length=1024) + + + +class CommunityPost(TimeInfoBase): + title = models.CharField(max_length=255) + category = models.CharField(max_length=255) + content = models.CharField(max_length=1024*8) + likes = models.IntegerField(default=0) + +class CommunityPostReports(TimeInfoBase): + post = models.ForeignKey(CommunityPost, on_delete=models.CASCADE) + # user = something + +class CommunityComment(TimeInfoBase): + post = models.ForeignKey(CommunityPost, on_delete=models.CASCADE) + content = models.CharField(max_length=1024*8) + likes = models.IntegerField(default=0) \ No newline at end of file diff --git a/schasite/templates/schasite/authenticated_base.html b/schasite/templates/schasite/authenticated_base.html index 7a62eb5..63cc43a 100644 --- a/schasite/templates/schasite/authenticated_base.html +++ b/schasite/templates/schasite/authenticated_base.html @@ -13,25 +13,74 @@ +