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()
124 changes: 124 additions & 0 deletions Planteer/Planteer/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""
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/
"""

import os
from pathlib import Path

# 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-rwq+8)*tp(5d4#=tcxp!emmgh$fe8rz7yx6dy56))%!-g(6l)x'

# 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',
'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': [BASE_DIR / 'templates'],
'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')
30 changes: 30 additions & 0 deletions Planteer/Planteer/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
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('accounts/', include('accounts.urls'))
]

urlpatterns += 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 AccountConfig(AppConfig):
name = 'accounts'
Empty file.
5 changes: 5 additions & 0 deletions Planteer/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.db import models


# Create your models here.

29 changes: 29 additions & 0 deletions Planteer/accounts/templates/accounts/signin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends 'base.html' %}

{% block title %} Sign up new user {% endblock %}

{% block content %}

<div class="countainer d-flex flex-column justify-content-center align-items-center">

<h2 class="mb-4 mt-4">Sign In</h2>
<form action="{% url 'accounts:sign_in' %}{% if 'next' in request.GET %}?next={{request.GET.next}}{% endif %}" class="d-flex flex-column gap-3 w-50" method="POST" enctype="multipart/form-data">
{% csrf_token %}



<div class="form-floating">
<input type="text" class="form-control" id="floatingInput" placeholder="username" name="username">
<label for="floatingInput">User name</label>
</div>

<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="password" name="password">
<label for="floatingPassword">Password</label>
</div>

<button class="btn btn-primary w-100 py-2" type="submit">Sign in</button>
</form>
</div>

{% endblock %}
42 changes: 42 additions & 0 deletions Planteer/accounts/templates/accounts/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends 'base.html' %}

{% block title %} Sign up new user {% endblock %}

{% block content %}

<div class="countainer d-flex flex-column justify-content-center align-items-center">

<h2 class="mb-4 mt-4">Sign Up</h2>
<form action="{% url 'accounts:sign_up' %}" class="d-flex flex-column gap-3 w-50" method="POST" enctype="multipart/form-data">
{% csrf_token %}

<div class="form-floating">
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com" name="email">
<label for="floatingInput">Email address</label>
</div>

<div class="form-floating">
<input type="text" class="form-control" id="floatingInput" placeholder="username" name="username">
<label for="floatingInput">User name</label>
</div>

<div class="form-floating">
<input type="text" class="form-control" id="floatingInput" placeholder="First name" name="first_name">
<label for="floatingInput">First name</label>
</div>

<div class="form-floating">
<input type="text" class="form-control" id="floatingInput" placeholder="Last name" name="last_name">
<label for="floatingInput">Last name</label>
</div>

<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="password" name="password">
<label for="floatingPassword">Password</label>
</div>

<button class="btn btn-primary w-100 py-2" type="submit">Sign up</button>
</form>
</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.
11 changes: 11 additions & 0 deletions Planteer/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from . import views
from django.urls import path

app_name = 'accounts'

urlpatterns = [
path('signup/', views.sign_up, name='sign_up'),
path('signin/', views.sign_in, name='sign_in'),
path('logout/', views.log_out, name='log_out'),

]
44 changes: 44 additions & 0 deletions Planteer/accounts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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"], first_name=request.POST["first_name"], last_name=request.POST["last_name"], email=request.POST["email"], password=request.POST["password"])
new_user.save()
messages.success(request, "Registered User Successfuly", "alert-success")
return redirect(request.GET.get("next", "/"))
except Exception as e:
print(e)


return render(request, 'accounts/signup.html', {})


def sign_in(request:HttpRequest):

if request.method == "POST":
user = authenticate(request, username=request.POST["username"], password=request.POST["password"])

if user:
login(request, user)
messages.success(request, "Logged in successfully", "alert-success")
return redirect("main:home_view")

else:
messages.error(request, "Please try again. You credentials are wrong", "alert-danger")
return render(request, 'accounts/signin.html', {})


def log_out(request:HttpRequest):

logout(request)
messages.success(request, "Logged out successsfully", "alert-warning")

return redirect(request.GET.get("next", "/"))
Binary file added Planteer/db.sqlite3
Binary file not shown.
Empty file added Planteer/main/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Planteer/main/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/main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
name = 'main'
25 changes: 25 additions & 0 deletions Planteer/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 6.0.4 on 2026-04-17 20:53

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Contact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('email', models.EmailField(max_length=254)),
('message', models.TextField()),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
]
Empty file.
10 changes: 10 additions & 0 deletions Planteer/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

# Create your models here.

class Contact(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailField()
message = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
Loading