Skip to content

completed #2

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

Open
wants to merge 13 commits into
base: main
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Pawtential/.DS_Store
Binary file not shown.
Empty file.
16 changes: 16 additions & 0 deletions Pawtential/Pawtential/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Pawtential 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/5.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Pawtential.settings')

application = get_asgi_application()
135 changes: 135 additions & 0 deletions Pawtential/Pawtential/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
"""
Django settings for Pawtential project.

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

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""

from pathlib import Path
import os


# 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/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-3!tw7xfpn(!-ju07_(yphklcdwe%u37)(0_=wc)t42dldt9s@$'

# 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',
'main',
'accounts',
'adoptions',
'donations',
'pets',
'widget_tweaks',

]

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 = 'Pawtential.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'Pawtential.wsgi.application'


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

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


# Password validation
# https://docs.djangoproject.com/en/5.1/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/5.1/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/5.1/howto/static-files/

STATIC_URL = 'static/'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
30 changes: 30 additions & 0 deletions Pawtential/Pawtential/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
URL configuration for Pawtential project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/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 import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('',include("main.urls")),
path('accounts/',include("accounts.urls")),
path('adoptions/',include("adoptions.urls")),
path('donations/',include("donations.urls")),
path('pets/',include("pets.urls")),
] +static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

16 changes: 16 additions & 0 deletions Pawtential/Pawtential/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Pawtential 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/5.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Pawtential.settings')

application = get_wsgi_application()
Empty file added Pawtential/accounts/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions Pawtential/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.contrib import admin
from .models import IndividualUser, Shelter
# Register your models here.

class IndividualUserAdmin(admin.ModelAdmin):
list_display = ('user', 'first_name', 'last_name', 'email', 'phone_number', 'birth_date', 'profile_picture')
search_fields = ['user__username', 'email', 'first_name', 'last_name']
list_filter = ['birth_date']


class ShelterAdmin(admin.ModelAdmin):
list_display = ('user', 'name', 'phone_number', 'address', 'license_number', 'profile_picture')
search_fields = ['user__username', 'name', 'phone_number', 'address']
list_filter = ['address']

admin.site.register(IndividualUser, IndividualUserAdmin)
admin.site.register(Shelter, ShelterAdmin)
6 changes: 6 additions & 0 deletions Pawtential/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'
16 changes: 16 additions & 0 deletions Pawtential/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django import forms
from .models import IndividualUser, Shelter


class IndividualUserForm(forms.ModelForm):
class Meta:
model = IndividualUser
fields = ['first_name', 'last_name', 'username', 'email', 'birth_date', 'phone_number', 'bio', 'profile_picture']
widgets = {
'birth_date': forms.DateInput(attrs={'type': 'date'}),
}
class ShelterProfileForm(forms.ModelForm):
class Meta:
model = Shelter
fields = ['name', 'phone_number', 'address', 'license_number', 'bio', 'profile_picture']

49 changes: 49 additions & 0 deletions Pawtential/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 5.1.3 on 2024-11-29 14:21

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='IndividualUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('username', models.CharField(max_length=100, unique=True)),
('email', models.EmailField(max_length=254, unique=True)),
('password', models.CharField(max_length=255)),
('birth_date', models.DateField(blank=True, null=True)),
('profile_picture', models.ImageField(blank=True, default='images/default_profile_pic.jpg', null=True, upload_to='profile_pics/')),
('phone_number', models.CharField(blank=True, max_length=15, null=True)),
('bio', models.TextField(blank=True, null=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='individual_user', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Shelter',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('username', models.CharField(max_length=100, unique=True)),
('email', models.EmailField(max_length=254, unique=True)),
('password', models.CharField(max_length=255)),
('phone_number', models.CharField(max_length=15)),
('address', models.CharField(max_length=255)),
('profile_picture', models.ImageField(blank=True, null=True, upload_to='profile_pics/')),
('bio', models.TextField(blank=True, null=True)),
('license_number', models.CharField(max_length=50, unique=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='shelter', to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
38 changes: 38 additions & 0 deletions Pawtential/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class IndividualUser(models.Model):

user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='individual_user')
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
username = models.CharField(max_length=100, unique=True)
email = models.EmailField(unique=True)
password = models.CharField(max_length=255)
birth_date = models.DateField(null=True,blank=True)
profile_picture = models.ImageField(upload_to='profile_pics/',blank=True , null=True , default='images/default_profile_pic.jpg' )
phone_number = models.CharField(max_length=15,blank=True,null=True)
bio = models.TextField(blank=True,null=True)

USERNAME_FIELD = 'username'
def __str__(self):
return f"{self.first_name} {self.last_name} ({self.username})"

class Shelter(models.Model):

user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='shelter')
name = models.CharField(max_length=200)
username = models.CharField(max_length=100, unique=True)
email = models.EmailField(unique=True)
password = models.CharField(max_length=255)
phone_number = models.CharField(max_length=15)
address = models.CharField(max_length=255)
profile_picture = models.ImageField(upload_to='profile_pics/', blank=True, null=True)
bio = models.TextField(blank=True,null=True)
license_number = models.CharField(max_length=50, unique=True)

USERNAME_FIELD = 'username'
def __str__(self):
return super().__str__()
Loading