diff --git a/account/admin.py b/account/admin.py index a2cb0ae..ad261e1 100644 --- a/account/admin.py +++ b/account/admin.py @@ -2,7 +2,7 @@ from .forms import CustomUserCreationForm, CustomUserChangeForm from django.contrib.auth.forms import AdminPasswordChangeForm from django.contrib.auth.admin import UserAdmin -from .models import CustomUser +from .models import CustomUser, ChurchGroup class CustomUserAdmin(UserAdmin): @@ -47,3 +47,5 @@ class CustomUserAdmin(UserAdmin): admin.site.register(CustomUser, CustomUserAdmin) # Here + +admin.site.register(ChurchGroup) # Here diff --git a/account/migrations/0001_initial.py b/account/migrations/0001_initial.py index c304d70..84d76ce 100644 --- a/account/migrations/0001_initial.py +++ b/account/migrations/0001_initial.py @@ -1,8 +1,8 @@ -# Generated by Django 4.0.8 on 2023-01-01 00:47 +# Generated by Django 4.0.8 on 2023-01-21 17:14 -import account.managers from django.db import migrations, models import django.utils.timezone +import account.managers class Migration(migrations.Migration): @@ -17,22 +17,40 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CustomUser', fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), - ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), + ('id', models.BigAutoField(auto_created=True, + primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField( + max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField( + blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, + help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('first_name', models.CharField(blank=True, + max_length=150, verbose_name='first name')), + ('last_name', models.CharField(blank=True, + max_length=150, verbose_name='last name')), + ('is_staff', models.BooleanField(default=False, + help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField( + default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField( + default=django.utils.timezone.now, verbose_name='date joined')), + ('email', models.EmailField(max_length=254, + unique=True, verbose_name='email address')), + ('firstname', models.CharField(max_length=256)), + ('lastname', models.CharField(max_length=256)), + ('role', models.CharField(choices=[ + ('admin', 'admin'), ('admin', 'admin')], max_length=50)), + ('category', models.CharField(choices=[('unknown', 'unknown'), ('children', 'children'), ( + 'teeneger', 'teeneger'), ('adult', 'adult')], default='unknown', max_length=20)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', + related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', + related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), ], options={ - 'verbose_name': 'custom user', - 'verbose_name_plural': 'custom users', + 'verbose_name': 'user', + 'verbose_name_plural': 'users', }, managers=[ ('objects', account.managers.CustomUserManager()), diff --git a/account/migrations/0002_alter_customuser_options_customuser_type.py b/account/migrations/0002_alter_customuser_options_customuser_type.py deleted file mode 100644 index 4d759f9..0000000 --- a/account/migrations/0002_alter_customuser_options_customuser_type.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:13 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='customuser', - options={'verbose_name': 'user', 'verbose_name_plural': 'users'}, - ), - migrations.AddField( - model_name='customuser', - name='type', - field=models.CharField(choices=[('unknown', 'unknown'), ('children', 'children'), ('teeneger', 'teeneger'), ('adult', 'adult')], default='unknown', max_length=20), - ), - ] diff --git a/account/migrations/0002_churchgroup.py b/account/migrations/0002_churchgroup.py new file mode 100644 index 0000000..63455fc --- /dev/null +++ b/account/migrations/0002_churchgroup.py @@ -0,0 +1,31 @@ +# Generated by Django 4.0.8 on 2023-01-21 17:30 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='ChurchGroup', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('name', models.CharField(max_length=256)), + ('purpose', models.CharField(max_length=256)), + ('leader', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='leader', to=settings.AUTH_USER_MODEL)), + ('memebers', models.ManyToManyField(to=settings.AUTH_USER_MODEL)), + ], + options={ + 'ordering': ('-created_at',), + }, + ), + ] diff --git a/account/migrations/0003_rename_memebers_churchgroup_members.py b/account/migrations/0003_rename_memebers_churchgroup_members.py new file mode 100644 index 0000000..f18fa72 --- /dev/null +++ b/account/migrations/0003_rename_memebers_churchgroup_members.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.8 on 2023-01-21 17:33 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0002_churchgroup'), + ] + + operations = [ + migrations.RenameField( + model_name='churchgroup', + old_name='memebers', + new_name='members', + ), + ] diff --git a/account/migrations/0003_rename_type_customuser_category.py b/account/migrations/0003_rename_type_customuser_category.py deleted file mode 100644 index 5d3b1fd..0000000 --- a/account/migrations/0003_rename_type_customuser_category.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:15 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0002_alter_customuser_options_customuser_type'), - ] - - operations = [ - migrations.RenameField( - model_name='customuser', - old_name='type', - new_name='category', - ), - ] diff --git a/account/migrations/0004_alter_customuser_options.py b/account/migrations/0004_alter_customuser_options.py new file mode 100644 index 0000000..f68c124 --- /dev/null +++ b/account/migrations/0004_alter_customuser_options.py @@ -0,0 +1,17 @@ +# Generated by Django 4.0.8 on 2023-01-21 18:18 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0003_rename_memebers_churchgroup_members'), + ] + + operations = [ + migrations.AlterModelOptions( + name='customuser', + options={'ordering': ('-id',), 'verbose_name': 'user', 'verbose_name_plural': 'users'}, + ), + ] diff --git a/account/migrations/0004_customuser_firstname_customuser_lastname.py b/account/migrations/0004_customuser_firstname_customuser_lastname.py deleted file mode 100644 index 015810e..0000000 --- a/account/migrations/0004_customuser_firstname_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:23 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0003_rename_type_customuser_category'), - ] - - operations = [ - migrations.AddField( - model_name='customuser', - name='firstname', - field=models.CharField(blank=True, max_length=256, null=True), - ), - migrations.AddField( - model_name='customuser', - name='lastname', - field=models.CharField(blank=True, max_length=256, null=True), - ), - ] diff --git a/account/migrations/0005_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0005_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index c5bbd5d..0000000 --- a/account/migrations/0005_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:31 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0004_customuser_firstname_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(default='', max_length=256), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(blank=True, default='', max_length=256, null=True), - ), - ] diff --git a/account/migrations/0006_alter_customuser_lastname.py b/account/migrations/0006_alter_customuser_lastname.py deleted file mode 100644 index 4f3f8af..0000000 --- a/account/migrations/0006_alter_customuser_lastname.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:34 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0005_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(default='', max_length=256), - ), - ] diff --git a/account/migrations/0007_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0007_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index b5be9de..0000000 --- a/account/migrations/0007_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:36 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0006_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(default='', max_length=256, null=True), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(default='', max_length=256, null=True), - ), - ] diff --git a/account/migrations/0008_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0008_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index a109b0f..0000000 --- a/account/migrations/0008_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:37 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0007_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(default='', max_length=256), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(default='', max_length=256), - ), - ] diff --git a/account/migrations/0009_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0009_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index 8d812dc..0000000 --- a/account/migrations/0009_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:40 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0008_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(default='', max_length=256, null=True), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(default='', max_length=256, null=True), - ), - ] diff --git a/account/migrations/0010_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0010_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index 6e1a513..0000000 --- a/account/migrations/0010_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:41 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0009_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(blank=True, default='', max_length=256), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(blank=True, default='', max_length=256), - ), - ] diff --git a/account/migrations/0011_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0011_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index d75b73a..0000000 --- a/account/migrations/0011_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0010_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(default='', max_length=256), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(default='', max_length=256), - ), - ] diff --git a/account/migrations/0012_alter_customuser_firstname_alter_customuser_lastname.py b/account/migrations/0012_alter_customuser_firstname_alter_customuser_lastname.py deleted file mode 100644 index d04c286..0000000 --- a/account/migrations/0012_alter_customuser_firstname_alter_customuser_lastname.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-03 20:58 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0011_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='firstname', - field=models.CharField(max_length=256), - ), - migrations.AlterField( - model_name='customuser', - name='lastname', - field=models.CharField(max_length=256), - ), - ] diff --git a/account/migrations/0013_customuser_role.py b/account/migrations/0013_customuser_role.py deleted file mode 100644 index e286097..0000000 --- a/account/migrations/0013_customuser_role.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.0.8 on 2023-01-19 14:21 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0012_alter_customuser_firstname_alter_customuser_lastname'), - ] - - operations = [ - migrations.AddField( - model_name='customuser', - name='role', - field=models.CharField(choices=[('admin', 'admin'), ('admin', 'admin')], default='user', max_length=50), - preserve_default=False, - ), - ] diff --git a/account/models.py b/account/models.py index 3bbaaa0..b80be49 100644 --- a/account/models.py +++ b/account/models.py @@ -3,9 +3,11 @@ from django.contrib.auth.models import AbstractUser from .managers import CustomUserManager from .enums import CATEGORY, ROLES +from core.models import AuditableModel +from django.contrib.auth.models import PermissionsMixin -class CustomUser(AbstractUser): +class CustomUser(AbstractUser, PermissionsMixin): username = None # Here email = models.EmailField('email address', unique=True) # Here firstname = models.CharField(max_length=256) # Here @@ -20,6 +22,22 @@ class CustomUser(AbstractUser): class Meta: verbose_name = "user" verbose_name_plural = "users" + ordering = ('-id',) def __str__(self): return f'{self.firstname} {self.lastname}' + + +class ChurchGroup(AuditableModel): + name = models.CharField(max_length=256) + purpose = models.CharField(max_length=256) # Here + leader = models.ForeignKey( + CustomUser, on_delete=models.SET_NULL, null=True, related_name='leader') + members = models.ManyToManyField( + CustomUser, related_name="group_list", blank=True) + + class Meta: + ordering = ('-created_at',) + + def __str__(self): + return f'{self.name}' diff --git a/account/serializers.py b/account/serializers.py index aa9444e..fe33b53 100644 --- a/account/serializers.py +++ b/account/serializers.py @@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model from .managers import CustomUserManager from rest_framework import serializers -from .models import CustomUser +from .models import CustomUser, ChurchGroup class BasicUserSerializer(serializers.ModelSerializer): @@ -49,7 +49,28 @@ def validate_current_password(self, value): return value +class ChurchGroupSerializer(serializers.ModelSerializer): + class Meta: + model = ChurchGroup + fields = '__all__' + + +class UserChurchGroupSerializer(serializers.ModelSerializer): + + class Meta: + model = ChurchGroup + fields = ("id", 'name') + + class ListUserSerializer(serializers.ModelSerializer): + group_list = UserChurchGroupSerializer(many=True, read_only=True) + class Meta: model = CustomUser - fields = ["id", 'email', "firstname", "lastname", "category"] + order = ('-created_at') + fields = ("id", 'email', "firstname", + "lastname", "category", "group_list") + + def to_representation(self, instance): + print(instance) + return super().to_representation(instance) diff --git a/attendance/models.py b/attendance/models.py index 2f1dfa2..91da9bf 100644 --- a/attendance/models.py +++ b/attendance/models.py @@ -13,5 +13,5 @@ class Attendance (AuditableModel): class Meta: ordering = ('-created_at',) - def __str__(self) -> str: - return self.id + def __str__(self) -> str: + return self.id diff --git a/blog/serializers.py b/blog/serializers.py index 2260454..8c03cfb 100644 --- a/blog/serializers.py +++ b/blog/serializers.py @@ -10,8 +10,6 @@ class CommentSerializer(serializers.ModelSerializer): class Meta: model = Comment - # fields = ('id', 'title', 'description', 'completed') - # Shortcut for getting all fields fields = '__all__' diff --git a/blog/urls copy.py b/blog/urls copy.py new file mode 100644 index 0000000..5761661 --- /dev/null +++ b/blog/urls copy.py @@ -0,0 +1,18 @@ +from django.urls import path, include +from .views import PostCreateAPIView, PostListAPIView, PostRetrieveAPIView, PostDestroyAPIView, PostUpdateAPIView, CommentListCreateAPIView, CommentRetrieveAPIView, CommentDestroyAPIView, CommentUpdateAPIView + +urlpatterns = [ + path('posts//', PostRetrieveAPIView.as_view(), + name="Post_detail"), + path('posts/create/', PostCreateAPIView.as_view(), name="post_create"), + path('posts/', PostListAPIView.as_view(), name="post_list"), + path('posts//', PostUpdateAPIView.as_view(), name="post_update"), + path('posts//', PostDestroyAPIView.as_view(), + name="post_delete"), + path('coments//', CommentRetrieveAPIView.as_view(), + name="comment_detail"), + path('coments/', CommentListCreateAPIView.as_view(), name="comment_list"), + path('coments//', CommentUpdateAPIView.as_view(), name="comment_update"), + path('coments//', CommentDestroyAPIView.as_view(), + name="event_delete"), +] diff --git a/core/settings.py b/core/settings.py index 37cd6ae..88bf521 100644 --- a/core/settings.py +++ b/core/settings.py @@ -67,7 +67,8 @@ "event", "blog", "poll", - "message" + "message", + "siteinfo" ] # AUTH_USER_MODEL = "users.CustomUser" diff --git a/readme.md b/readme.md index a25cc4d..33c691b 100644 --- a/readme.md +++ b/readme.md @@ -16,18 +16,15 @@ ## Features (Content Mgt System) - User management (roles/permissions) / Members directory / Groups -- Attendance system -- offering and donation -- Pledges managemnts -- Public display and/or reporting for collections, donations, offerings -- e-bible +- Events (meetings, events and programs) for activities Callender +- Attendance system for events - Blog (post & comments ) +- pleadges, offering and donation +- Prayer Request ,Contact - Polls and Surveys -- Events Callender for activities, meetings, events and programs -- Prayer Request -- Contact - User Audit and logs - Email marketing - Live streeming - schedule meetings +- e-bible - Video and audio for sermons diff --git a/siteinfo/__init__.py b/siteinfo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/siteinfo/admin.py b/siteinfo/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/siteinfo/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/siteinfo/apps.py b/siteinfo/apps.py new file mode 100644 index 0000000..3c4e0a6 --- /dev/null +++ b/siteinfo/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SiteinfoConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'siteinfo' diff --git a/siteinfo/migrations/__init__.py b/siteinfo/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/siteinfo/models.py b/siteinfo/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/siteinfo/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/siteinfo/serializers.py b/siteinfo/serializers.py new file mode 100644 index 0000000..8c03cfb --- /dev/null +++ b/siteinfo/serializers.py @@ -0,0 +1,23 @@ +# django #selenium #webscraping +from rest_framework import serializers +from taggit.serializers import (TagListSerializerField, + TaggitSerializer) +from .models import Post, Comment + + +class CommentSerializer(serializers.ModelSerializer): + author = serializers.UUIDField() + + class Meta: + model = Comment + fields = '__all__' + + +class PostSerializer(TaggitSerializer, serializers.ModelSerializer): + tags = TagListSerializerField() + comments = CommentSerializer(many=True, read_only=True) + author = serializers.UUIDField() + + class Meta: + model = Post + fields = ('title', "author", "slug", "comments", "tags", "status") diff --git a/siteinfo/tests.py b/siteinfo/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/siteinfo/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here.