Skip to content
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
Empty file added Planteer/Planteer/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions Planteer/Planteer/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Planteer 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/6.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

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

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

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

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/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/6.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-p^&t_=40ah+m*27wv-@q0shitg%&%t*trdg4)*d8f#=7@2h@q-'

# 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',
'plants',
'contact',
'accounts',
]

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

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

WSGI_APPLICATION = 'Planteer.wsgi.application'


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

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


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

STATIC_URL = 'static/'

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

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/6.0/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('plants/', include("plants.urls")),
path('contact/', include('contact.urls')),
path('accounts/', include('accounts.urls')),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions Planteer/Planteer/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Planteer 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/6.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
Empty file added Planteer/accounts/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Planteer/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions Planteer/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
name = 'accounts'
Empty file.
3 changes: 3 additions & 0 deletions Planteer/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Empty file.
36 changes: 36 additions & 0 deletions Planteer/accounts/templates/accounts/signin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "main/base.html" %}

{% block content %}
<div class="container d-flex justify-content-center align-items-center" style="min-height: 80vh;">
<div class="auth-card">
<div class="auth-header text-center mb-4">
<h2 class="fw-bold" style="color: var(--accent-gold); letter-spacing: 3px;">SIGN IN</h2>
<p style="color: var(--text-muted); font-size: 0.85rem;">WELCOME BACK TO PLANTEER SYSTEM</p>
</div>

<form method="POST">
{% csrf_token %}

<div class="mb-4">
<label class="form-label custom-label">USERNAME</label>
<input type="text" name="username" class="form-control custom-input" placeholder="Your username" required>
</div>

<div class="mb-4">
<label class="form-label custom-label">PASSWORD</label>
<input type="password" name="password" class="form-control custom-input" placeholder="••••••••" required>
</div>

<button type="submit" class="btn btn-gold-action w-100 py-3 fw-bold mt-2">
ACCESS ACCOUNT
</button>
</form>

<div class="text-center mt-4 border-top pt-3" style="border-color: rgba(233, 207, 143, 0.1) !important;">
<p style="color: var(--text-muted); font-size: 0.85rem;">
NOT A MEMBER? <a href="{% url 'accounts:sign_up' %}" style="color: var(--accent-gold); text-decoration: none;" class="fw-bold">JOIN NOW</a>
</p>
</div>
</div>
</div>
{% endblock %}
51 changes: 51 additions & 0 deletions Planteer/accounts/templates/accounts/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% extends "main/base.html" %}

{% block content %}
<div class="container d-flex justify-content-center align-items-center" style="min-height: 100vh; padding: 50px 0;">
<div class="auth-card">
<div class="auth-header text-center mb-4">
<h2 class="fw-bold" style="color: var(--accent-gold); letter-spacing: 2px;">JOIN PLANTEER</h2>
<p style="color: var(--text-muted); font-size: 0.9rem;">Create your botanical profile</p>
</div>

<form method="POST">
{% csrf_token %}

<div class="mb-3">
<label class="form-label custom-label">FIRST NAME</label>
<input type="text" name="first_name" class="form-control custom-input" placeholder="Enter your first name" required>
</div>

<div class="mb-3">
<label class="form-label custom-label">LAST NAME</label>
<input type="text" name="last_name" class="form-control custom-input" placeholder="Enter your last name" required>
</div>

<div class="mb-3">
<label class="form-label custom-label">USERNAME</label>
<input type="text" name="username" class="form-control custom-input" placeholder="Choose a unique username" required>
</div>

<div class="mb-3">
<label class="form-label custom-label">EMAIL ADDRESS</label>
<input type="email" name="email" class="form-control custom-input" placeholder="email@example.com" required>
</div>

<div class="mb-4">
<label class="form-label custom-label">PASSWORD</label>
<input type="password" name="password" class="form-control custom-input" placeholder="••••••••" required>
</div>

<button type="submit" class="btn btn-gold-action w-100 py-3 fw-bold">
CREATE ACCOUNT
</button>
</form>

<div class="text-center mt-4 border-top pt-3" style="border-color: rgba(233, 207, 143, 0.1) !important;">
<p style="color: var(--text-muted); font-size: 0.85rem;">
ALREADY A MEMBER? <a href="{% url 'accounts:sign_in' %}" style="color: var(--accent-gold); text-decoration: none;" class="fw-bold">SIGN IN</a>
</p>
</div>
</div>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions Planteer/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions Planteer/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path
from . import views

app_name = 'accounts'

urlpatterns = [
path("sign_up/",views.sign_up,name="sign_up"),
path("signin/", views.sign_in, name="sign_in"),
path("logout/", views.log_out, name="log_out"),
]
52 changes: 52 additions & 0 deletions Planteer/accounts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from django.shortcuts import render, redirect
from django.http import HttpRequest,HttpResponse
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages

# Create your views here.


def sign_up(request: HttpRequest):
if request.method == "POST":
try:
new_user = User.objects.create_user(
username=request.POST["username"],
password=request.POST["password"],
email=request.POST.get("email", ""),
first_name=request.POST.get("first_name", ""),
last_name=request.POST.get("last_name", "")
)

messages.success(request, "Registered User Successfully", "alert-success")
return redirect("accounts:sign_in")

except IntegrityError:
messages.error(request, "Username already exists. Please choose another one.", "alert-danger")
except Exception as e:
print(f"Error during registration: {e}")
messages.error(request, "An error occurred. Please try again.", "alert-danger")

return render(request, "accounts/signup.html")

def sign_in(request: HttpRequest):
if request.method == "POST":
username_val = request.POST.get("username")
password_val = request.POST.get("password")

user = authenticate(request, username=username_val, password=password_val)

if user:
login(request, user)
messages.success(request, f"Welcome back, {user.username}", "alert-success")
return redirect(request.GET.get("next", "main:home_view"))
else:
messages.error(request, "Invalid credentials, please try again.", "alert-danger")

return render(request, "accounts/signin.html")

def log_out(request: HttpRequest):
logout(request)
messages.success(request, "Logged out successfully", "alert-warning")

return redirect("main:home_view")
Empty file added Planteer/contact/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Planteer/contact/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions Planteer/contact/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ContactConfig(AppConfig):
name = 'contact'
Loading