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

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

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

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-w!6f7p84f7wv5_pll3p^3smum4t+-!g-!5np5$alny8ewfmw64'

# 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',
'plant',
'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/5.2/ref/settings/#databases

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


# Password validation
# https://docs.djangoproject.com/en/5.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/5.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Riyadh'

USE_I18N = True

USE_TZ = True


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

STATIC_URL = 'static/'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
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/5.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 . import settings

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls')),
path('plants/', include('plant.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/5.2/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.
6 changes: 6 additions & 0 deletions Planteer/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'
27 changes: 27 additions & 0 deletions Planteer/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.2.13 on 2026-04-28 06:42

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='Profile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('about', models.TextField(blank=True)),
('avatar', models.ImageField(default='images/avatars/avatar.webp', upload_to='images/avatars/')),
('twitch_link', models.URLField(blank=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
13 changes: 13 additions & 0 deletions Planteer/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.db import models
from django.contrib.auth.models import User

#Create your models here.

class Profile(models.Model):
user = models.OneToOneField(User , on_delete=models.CASCADE)
about = models.TextField(blank=True)
avatar = models.ImageField(upload_to="images/avatars/",default="images/avatars/avatar.webp")
twitch_link= models.URLField(blank=True)

def __str__(self) -> str:
return f"Profile {self.user.username}"
79 changes: 79 additions & 0 deletions Planteer/accounts/templates/accounts/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{% extends 'main/base.html'%}


{% block title %} profile for {{user.username}} {% endblock %}

{% block content %}


<div class="row">

<div class="col-2">

<img src="{{user.profile.avatar.url}}" class="w-100 rounded-circle" />
<h5>@{{user.username}}</h5>
<a href="{{user.profile.twitch_link}}" target="_blank"><i class="bi bi-twitch"></i></a>
<!-- {% if request.user == user %}
<a href="{% url 'accounts:update_user_profile' %}"><i class="bi bi-pencil-square"></i></a>
{% endif %} -->
</div>

<!-- PROFILE -->
<div class="col">

<div class="d-flex flex-column gap-3">
<p>{{user.profile.about}}</p>


<hr />

<h3>{{user.first_name}} Comments</h3>

{% for comment in user.comments_set.all %}
<div class="d-flex flex-column p-3 shadow">
<div class="d-flex justify-content-between align-items-center">
<h4>{{comment.user.first_name}} {{comment.user.last_name}}</h4>

</div>

<p>{{review.comment}}</p>
<a href="{% url 'games:game_detail_view' review.game.id %}">
<h5>On Game: {{review.game.title }}</h5>
</a>
<p class="text-muted">{{review.created_at}}</p>
</div>
{% endfor %}


{% if request.user == user %}

<h3>Bookmarks</h3>

<div class="row row-cols-3 gap-4">

{% for bookmark in request.user.bookmark_set.all %}

<div class="col d-flex flex-column gap-2 align-items-center p-4 shadow">
<img src="{{bookmark.game.poster.url}}" class="w-100" />
<a href="{% url 'games:game_detail_view' bookmark.game.id %}">
<h3>{{bookmark.game.title }}</h3>
</a>
</div>

{% endfor %}

</div>

{% endif %}

</div>

</div>

</div>





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


{% block title %} Sign In{% endblock %}

{% block content %}
<div class="container d-flex flex-column justify-content-center align-items-center mt-5">

<h2>Sign In</h2>

<form class="d-flex flex-column gap-3 w-50"
action="{% url 'accounts:signin_view' %}{% if 'next' in request.GET %}?next={{request.GET.next}}{% endif %}"
method="POST">
{% 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 %}
Loading