Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random2 #49

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL = "postgres://treasury_j9ac_user:YLRY8JKUT2v4TSfveeWRo96GYTaezmTo@dpg-clsnla5cm5oc73b8rf40-a.oregon-postgres.render.com/treasury_j9ac"
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
File renamed without changes.
Binary file added EventPlanner/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
Binary file added EventPlanner/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions EventPlanner/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for EventPlanner project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "EventPlanner.settings")

application = get_asgi_application()
File renamed without changes.
7 changes: 7 additions & 0 deletions EventPlanner/house/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin

# ----- In-Built Libraries -----
from .models import House

# ----- Model Registration -----
admin.site.register(House)
6 changes: 6 additions & 0 deletions EventPlanner/house/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class HouseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "house"
Empty file.
20 changes: 20 additions & 0 deletions EventPlanner/house/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ----- 3rd Party Libraries -----
from django.db import models

# ----- In-Built Libraries -----
from property.models import Property

# ----- Models -----
class House(models.Model):
STATUS = (
('occupied', 'occupied'),
('vacant', 'vacant'),
)
house_number = models.CharField(max_length=1000, blank=False)
type = models.CharField(max_length=1000, blank=False)
rent = models.FloatField(blank=False)
status = models.CharField(choices=STATUS, blank=False, default="vacant", max_length=1000)
property_id = models.ForeignKey(Property, on_delete=models.CASCADE)

def __str__(self):
return self.house_number
11 changes: 11 additions & 0 deletions EventPlanner/house/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ----- 3rd Party Libraries -----
from rest_framework import serializers

# ----- In-Built Libraries -----
from .models import House

# ----- Model Serializers ------
class HouseSerializer(serializers.ModelSerializer):
class Meta:
model = House
fields = "__all__"
55 changes: 55 additions & 0 deletions EventPlanner/house/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ----- 3rd Party Libraries -----
from django.test import TestCase
from django.urls import reverse

# ----- In-Built Libraries -----
from .models import Process_Statement

# ----- Tests -----
class PersonCRUDTests(TestCase):
def test_create_receipt(self):
new_receipt_data = {
'date': '2023-10-10 13:11:18',
'phonenumber': '07897***678',
'name': 'Charles',
'giving':'tithe',
'amount':'50.00',
'status':'UNSENT'
}
response = self.client.post(reverse('create_person'), data=new_receipt_data)
self.assertEqual(response.status_code, 302) # Assuming successful creation redirects

# Check if the new person is in the database
new_receipt = Process_Statement.objects.get(name='Charles')
self.assertEqual(new_receipt.phonenumber, '07897***678')

def test_read_person(self):
response = self.client.get(reverse('read_person', args=[self.person.id]))
self.assertEqual(response.status_code, 200) # Assuming successful read

# Check if the retrieved person's details are correct
self.assertContains(response, 'John Doe')
self.assertContains(response, 'john@example.com')

def test_update_person(self):
updated_data = {
'name': 'John Updated',
'email': 'john.updated@example.com',
'phonenumber': '1112223333',
'occupation': 'Updated Occupation'
}
response = self.client.post(reverse('update_person', args=[self.person.id]), data=updated_data)
self.assertEqual(response.status_code, 302) # Assuming successful update redirects

# Check if the person's details have been updated in the database
self.person.refresh_from_db()
self.assertEqual(self.person.name, 'John Updated')
self.assertEqual(self.person.phonenumber, '1112223333')

def test_delete_person(self):
response = self.client.post(reverse('delete_person', args=[self.person.id]))
self.assertEqual(response.status_code, 302) # Assuming successful delete redirects

# Check if the person has been deleted from the database
with self.assertRaises(Person.DoesNotExist):
Person.objects.get(name='John Doe')
20 changes: 20 additions & 0 deletions EventPlanner/house/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ----- 3rd Party Libraries -----
from django.urls import path

# ----- In-Built Libraries -----
from house import views

# ----- URL endpoints -----
house_list = views.HouseViews.as_view({
'post': 'create',
'get': 'list',
})
house_detail = views.HouseViews.as_view({
'get': 'retrieve',
'put': 'update',
})

urlpatterns = [
path("property", house_list, name='house_list'),
path('property/<int:pk>', house_detail, name="house_detail"),
]
12 changes: 12 additions & 0 deletions EventPlanner/house/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ----- 3rd Party Libraries -----
from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet

# ----- In-Built Libraries -----
from .models import House
from .serializers import HouseSerializer

# ----- CPU endpoints -----
class HouseViews(ModelViewSet):
queryset = House.object.all()
serializer_class = HouseSerializer
141 changes: 141 additions & 0 deletions EventPlanner/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
"""
Django settings for EventPlanner project.

Generated by 'django-admin startproject' using Django 4.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from dotenv import load_dotenv
from pathlib import Path
import os
import dj_database_url

load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-=knyc37!)x4rha&7e%_syzk0k8aw(raf6(86tyf==!u9x6h-i3"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"base",
"widget_tweaks",
"rest_framework",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "EventPlanner.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
BASE_DIR, "templates"
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "EventPlanner.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

'''
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

'''

DATABASES = {
"default":dj_database_url.parse(os.getenv("DATABASE_URL"))
}

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = "static/"
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static/"),
)

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
26 changes: 26 additions & 0 deletions EventPlanner/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
URL configuration for EventPlanner project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
path("admin/", admin.site.urls),
path('', include("base.urls")),
path('api/', include('api.urls')),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
16 changes: 16 additions & 0 deletions EventPlanner/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for EventPlanner project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "EventPlanner.settings")

application = get_wsgi_application()
Empty file added api/__init__.py
Empty file.
Binary file added api/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/views.cpython-310.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin

# ----- In-Built Libraries -----
from .models import Ministry

# Register your models here.
admin.site.register(Ministry)
6 changes: 6 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
Empty file added api/house/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions api/house/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin

# ----- In-Built Libraries -----
from .models import House

# ----- Model Registration -----
admin.site.register(House)
6 changes: 6 additions & 0 deletions api/house/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class HouseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "house"
Empty file.
Loading