Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d702332e91 |
Binary file not shown.
Binary file not shown.
@ -180,3 +180,7 @@ if EMAIL_USE_SSL:
|
|||||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,3 @@
|
|||||||
"""
|
|
||||||
URL configuration for config 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.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -27,3 +11,4 @@ urlpatterns = [
|
|||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += static("/assets/", document_root=settings.BASE_DIR / "assets")
|
urlpatterns += static("/assets/", document_root=settings.BASE_DIR / "assets")
|
||||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
41
core/migrations/0001_initial.py
Normal file
41
core/migrations/0001_initial.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-02-28 04:39
|
||||||
|
|
||||||
|
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')),
|
||||||
|
('course', models.CharField(blank=True, max_length=255)),
|
||||||
|
('year', models.CharField(blank=True, choices=[('Year 1', 'Year 1'), ('Year 2', 'Year 2'), ('Year 3', 'Year 3'), ('Year 4+', 'Year 4+'), ('Postgraduate', 'Postgraduate')], max_length=50)),
|
||||||
|
('location', models.CharField(blank=True, choices=[('Canley', 'Canley'), ('Leamington Spa', 'Leamington Spa'), ('On-Campus', 'On-Campus'), ('Coventry', 'Coventry'), ('Other', 'Other')], max_length=50)),
|
||||||
|
('looking_for', models.CharField(blank=True, choices=[('Friends', 'Friends'), ('Short-term', 'Short-term'), ('Long-term', 'Long-term')], max_length=50)),
|
||||||
|
('bio', models.TextField(blank=True, max_length=500)),
|
||||||
|
('is_subscribed', models.BooleanField(default=False)),
|
||||||
|
('last_online', models.DateTimeField(auto_now=True)),
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Photo',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('image', models.ImageField(upload_to='profile_photos/')),
|
||||||
|
('is_primary', models.BooleanField(default=False)),
|
||||||
|
('uploaded_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='photos', to='core.profile')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
@ -1,3 +1,62 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
# Create your models here.
|
class Profile(models.Model):
|
||||||
|
LOCATION_CHOICES = [
|
||||||
|
('Canley', 'Canley'),
|
||||||
|
('Leamington Spa', 'Leamington Spa'),
|
||||||
|
('On-Campus', 'On-Campus'),
|
||||||
|
('Coventry', 'Coventry'),
|
||||||
|
('Other', 'Other'),
|
||||||
|
]
|
||||||
|
LOOKING_FOR_CHOICES = [
|
||||||
|
('Friends', 'Friends'),
|
||||||
|
('Short-term', 'Short-term'),
|
||||||
|
('Long-term', 'Long-term'),
|
||||||
|
]
|
||||||
|
YEAR_CHOICES = [
|
||||||
|
('Year 1', 'Year 1'),
|
||||||
|
('Year 2', 'Year 2'),
|
||||||
|
('Year 3', 'Year 3'),
|
||||||
|
('Year 4+', 'Year 4+'),
|
||||||
|
('Postgraduate', 'Postgraduate'),
|
||||||
|
]
|
||||||
|
|
||||||
|
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
|
||||||
|
course = models.CharField(max_length=255, blank=True)
|
||||||
|
year = models.CharField(max_length=50, choices=YEAR_CHOICES, blank=True)
|
||||||
|
location = models.CharField(max_length=50, choices=LOCATION_CHOICES, blank=True)
|
||||||
|
looking_for = models.CharField(max_length=50, choices=LOOKING_FOR_CHOICES, blank=True)
|
||||||
|
bio = models.TextField(max_length=500, blank=True)
|
||||||
|
is_subscribed = models.BooleanField(default=False)
|
||||||
|
last_online = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.user.username}'s profile"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def primary_photo(self):
|
||||||
|
primary = self.photos.filter(is_primary=True).first()
|
||||||
|
if primary:
|
||||||
|
return primary
|
||||||
|
return self.photos.first()
|
||||||
|
|
||||||
|
class Photo(models.Model):
|
||||||
|
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='photos')
|
||||||
|
image = models.ImageField(upload_to='profile_photos/')
|
||||||
|
is_primary = models.BooleanField(default=False)
|
||||||
|
uploaded_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Photo for {self.profile.user.username}"
|
||||||
|
|
||||||
|
@receiver(post_save, sender=User)
|
||||||
|
def create_user_profile(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
Profile.objects.create(user=instance)
|
||||||
|
|
||||||
|
@receiver(post_save, sender=User)
|
||||||
|
def save_user_profile(sender, instance, **kwargs):
|
||||||
|
instance.profile.save()
|
||||||
@ -1,25 +1,131 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{% block title %}Knowledge Base{% endblock %}</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
{% if project_description %}
|
<title>{% block title %}Warwick Connect{% endblock %}</title>
|
||||||
<meta name="description" content="{{ project_description }}">
|
|
||||||
<meta property="og:description" content="{{ project_description }}">
|
<!-- Google Fonts -->
|
||||||
<meta property="twitter:description" content="{{ project_description }}">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
{% endif %}
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
{% if project_image_url %}
|
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
<meta property="og:image" content="{{ project_image_url }}">
|
|
||||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
<!-- Bootstrap 5 CDN -->
|
||||||
{% endif %}
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
{% load static %}
|
|
||||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
{% load static %}
|
||||||
{% block head %}{% endblock %}
|
<style>
|
||||||
|
:root {
|
||||||
|
--warwick-navy: #003366;
|
||||||
|
--accent-coral: #FF6B6B;
|
||||||
|
--bg-light: #F8FAFC;
|
||||||
|
--text-dark: #1E293B;
|
||||||
|
--text-muted: #64748B;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||||
|
background-color: var(--bg-light);
|
||||||
|
color: var(--text-dark);
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
||||||
|
padding: 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--warwick-navy) !important;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--warwick-navy);
|
||||||
|
border-color: var(--warwick-navy);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.6rem 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #002244;
|
||||||
|
border-color: #002244;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-accent {
|
||||||
|
background-color: var(--accent-coral);
|
||||||
|
border-color: var(--accent-coral);
|
||||||
|
color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.6rem 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-accent:hover {
|
||||||
|
background-color: #ff5252;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: none;
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
{% block extra_css %}{% endblock %}
|
||||||
|
</style>
|
||||||
|
{% block head %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% block content %}{% endblock %}
|
<nav class="navbar navbar-expand-lg">
|
||||||
</body>
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="{% url 'home' %}">Warwick Connect</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto align-items-center">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{% url 'dashboard' %}">Discovery</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{% url 'profile_edit' %}">My Profile</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item ms-lg-3">
|
||||||
|
<a class="btn btn-outline-danger btn-sm" href="{% url 'logout' %}">Log Out</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{% url 'login' %}">Log In</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item ms-lg-3">
|
||||||
|
<a class="btn btn-primary" href="{% url 'register' %}">Join Now</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</html>
|
<div class="container py-4">
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
{% block extra_js %}{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
211
core/templates/core/dashboard.html
Normal file
211
core/templates/core/dashboard.html
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Discover Students | Warwick Connect{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
<style>
|
||||||
|
.discovery-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||||
|
gap: 1.5rem;
|
||||||
|
margin-top: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid rgba(0,0,0,0.03);
|
||||||
|
box-shadow: 0 4px 15px rgba(0,0,0,0.02);
|
||||||
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-img-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 320px;
|
||||||
|
background-color: #E2E8F0;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 100%);
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
font-size: 3rem;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-info {
|
||||||
|
padding: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-name {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-meta {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-tag {
|
||||||
|
background-color: var(--bg-light);
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
padding: 0.35rem 0.75rem;
|
||||||
|
border-radius: 50px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.locked-overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(255, 255, 255, 0.4);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
z-index: 10;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.locked-card {
|
||||||
|
background: white;
|
||||||
|
padding: 1.5rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.locked-title {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.locked-price {
|
||||||
|
color: var(--accent-coral);
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discovery-title {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.discovery-subtitle {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.online-indicator {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 12px;
|
||||||
|
right: 12px;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: #10B981;
|
||||||
|
border: 2px solid white;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="header-section mt-4">
|
||||||
|
<h1 class="discovery-title">Who's Online</h1>
|
||||||
|
<p class="discovery-subtitle">Find fellow students at Warwick university.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="discovery-grid">
|
||||||
|
{% for profile in visible_profiles %}
|
||||||
|
<div class="profile-card">
|
||||||
|
<div class="profile-img-container">
|
||||||
|
{% if profile.primary_photo %}
|
||||||
|
<img src="{{ profile.primary_photo.image.url }}" class="profile-img" alt="{{ profile.user.username }}">
|
||||||
|
{% else %}
|
||||||
|
<div class="placeholder-img">{{ profile.user.username|slice:":1"|upper }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="online-indicator"></div>
|
||||||
|
</div>
|
||||||
|
<div class="profile-info">
|
||||||
|
<div class="profile-name">{{ profile.user.first_name|default:profile.user.username }}</div>
|
||||||
|
<div class="profile-meta">{{ profile.course|default:"Student" }} · {{ profile.year }}</div>
|
||||||
|
<div class="profile-tags">
|
||||||
|
<span class="badge-tag">{{ profile.location }}</span>
|
||||||
|
<span class="badge-tag">Looking for: {{ profile.looking_for }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% empty %}
|
||||||
|
<div class="text-center py-5 col-12">
|
||||||
|
<h3 class="text-muted">No students found yet. Be the first to join!</h3>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for profile in locked_profiles %}
|
||||||
|
<div class="profile-card">
|
||||||
|
<div class="profile-img-container" style="filter: blur(15px);">
|
||||||
|
<div class="placeholder-img">{{ profile.user.username|slice:":1"|upper }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="locked-overlay">
|
||||||
|
<div class="locked-card">
|
||||||
|
<div class="locked-title">Unlock Full Grid</div>
|
||||||
|
<div class="locked-price">£3.99/mo</div>
|
||||||
|
<button class="btn btn-primary btn-sm w-100">Subscribe</button>
|
||||||
|
<p class="small text-muted mt-2 mb-0">See all students online</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="profile-info" style="filter: blur(10px);">
|
||||||
|
<div class="profile-name">Student Name</div>
|
||||||
|
<div class="profile-meta">Course · Year</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if not is_subscribed and locked_profiles %}
|
||||||
|
<div class="alert mt-5 p-4 text-center rounded-4" style="background: white; border: 2px dashed #CBD5E1;">
|
||||||
|
<h4 class="fw-bold" style="color: var(--warwick-navy);">Ready to see everyone?</h4>
|
||||||
|
<p class="text-muted">Join other subscribers and unlock the full discovery grid, messaging, and more.</p>
|
||||||
|
<button class="btn btn-accent px-5">Subscribe for £3.99/month</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
@ -1,145 +1,128 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}{{ project_name }}{% endblock %}
|
{% block title %}Connect with Warwick Students | Warwick Connect{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block extra_css %}
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
<style>
|
||||||
:root {
|
.hero-section {
|
||||||
--bg-color-start: #6a11cb;
|
background: linear-gradient(135deg, #003366 0%, #004d99 100%);
|
||||||
--bg-color-end: #2575fc;
|
color: white;
|
||||||
--text-color: #ffffff;
|
padding: 6rem 0;
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
border-radius: 24px;
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
margin-top: 1rem;
|
||||||
}
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: 'Inter', sans-serif;
|
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
|
||||||
color: var(--text-color);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
body::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
|
|
||||||
animation: bg-pan 20s linear infinite;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes bg-pan {
|
|
||||||
0% {
|
|
||||||
background-position: 0% 0%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
.hero-section::after {
|
||||||
background-position: 100% 100%;
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -50px;
|
||||||
|
right: -50px;
|
||||||
|
width: 300px;
|
||||||
|
height: 300px;
|
||||||
|
background: rgba(255, 107, 107, 0.1);
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
.hero-title {
|
||||||
padding: 2rem;
|
font-size: 3.5rem;
|
||||||
}
|
font-weight: 800;
|
||||||
|
line-height: 1.1;
|
||||||
.card {
|
margin-bottom: 1.5rem;
|
||||||
background: var(--card-bg-color);
|
|
||||||
border: 1px solid var(--card-border-color);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 2.5rem 2rem;
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
-webkit-backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 1.2rem;
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
opacity: 0.92;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader {
|
|
||||||
margin: 1.5rem auto;
|
|
||||||
width: 56px;
|
|
||||||
height: 56px;
|
|
||||||
border: 4px solid rgba(255, 255, 255, 0.25);
|
|
||||||
border-top-color: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.runtime code {
|
.hero-subtitle {
|
||||||
background: rgba(0, 0, 0, 0.25);
|
font-size: 1.25rem;
|
||||||
padding: 0.15rem 0.45rem;
|
opacity: 0.9;
|
||||||
border-radius: 4px;
|
margin-bottom: 2.5rem;
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
max-width: 600px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sr-only {
|
.badge-warwick {
|
||||||
position: absolute;
|
background-color: rgba(255, 255, 255, 0.15);
|
||||||
width: 1px;
|
color: white;
|
||||||
height: 1px;
|
padding: 0.5rem 1rem;
|
||||||
padding: 0;
|
border-radius: 50px;
|
||||||
margin: -1px;
|
font-weight: 600;
|
||||||
overflow: hidden;
|
font-size: 0.9rem;
|
||||||
clip: rect(0, 0, 0, 0);
|
margin-bottom: 1.5rem;
|
||||||
border: 0;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
.feature-card {
|
||||||
position: absolute;
|
padding: 2.5rem;
|
||||||
bottom: 1rem;
|
background: white;
|
||||||
width: 100%;
|
border-radius: 20px;
|
||||||
text-align: center;
|
height: 100%;
|
||||||
font-size: 0.85rem;
|
border: 1px solid rgba(0,0,0,0.03);
|
||||||
opacity: 0.75;
|
box-shadow: 0 10px 30px rgba(0,0,0,0.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.feature-icon {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
background: var(--bg-light);
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
border-radius: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main>
|
<section class="hero-section text-center text-lg-start">
|
||||||
<div class="card">
|
<div class="container">
|
||||||
<h1>Analyzing your requirements and generating your app…</h1>
|
<div class="row align-items-center">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<div class="col-lg-7">
|
||||||
<span class="sr-only">Loading…</span>
|
<span class="badge-warwick">Exclusive for @warwick.ac.uk students</span>
|
||||||
|
<h1 class="hero-title">Discover your next connection at Warwick.</h1>
|
||||||
|
<p class="hero-subtitle">The only dating and networking platform dedicated exclusively to University of Warwick students. Find friends, study buddies, or something more.</p>
|
||||||
|
<div class="d-flex flex-column flex-sm-row gap-3">
|
||||||
|
<a href="{% url 'register' %}" class="btn btn-accent btn-lg px-5">Get Started</a>
|
||||||
|
<a href="{% url 'login' %}" class="btn btn-outline-light btn-lg px-5">Log In</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-5 d-none d-lg-block">
|
||||||
|
<!-- Simple abstract visual using shapes -->
|
||||||
|
<div class="position-relative" style="height: 400px;">
|
||||||
|
<div style="position: absolute; width: 200px; height: 200px; background: var(--accent-coral); border-radius: 50%; top: 50px; left: 50px; opacity: 0.8;"></div>
|
||||||
|
<div style="position: absolute; width: 150px; height: 150px; border: 3px solid white; border-radius: 16px; top: 150px; left: 150px; transform: rotate(15deg);"></div>
|
||||||
|
<div style="position: absolute; width: 80px; height: 80px; background: white; border-radius: 8px; top: 100px; left: 250px; opacity: 0.2;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
|
</section>
|
||||||
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
|
|
||||||
<p class="runtime">
|
<section class="py-5 mt-5">
|
||||||
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
|
<div class="row g-4">
|
||||||
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
|
<div class="col-md-4">
|
||||||
</p>
|
<div class="feature-card">
|
||||||
</div>
|
<div class="feature-icon">🎓</div>
|
||||||
</main>
|
<h3 class="h5 fw-bold">Verified Students Only</h3>
|
||||||
<footer>
|
<p class="text-muted mb-0">Every user is verified with a Warwick email address, ensuring a safe and authentic community.</p>
|
||||||
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
|
</div>
|
||||||
</footer>
|
</div>
|
||||||
{% endblock %}
|
<div class="col-md-4">
|
||||||
|
<div class="feature-card">
|
||||||
|
<div class="feature-icon">📍</div>
|
||||||
|
<h3 class="h5 fw-bold">Nearby Connections</h3>
|
||||||
|
<p class="text-muted mb-0">Whether you're in Leamington, Canley, or On-Campus, find students exactly where you are.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="feature-card">
|
||||||
|
<div class="feature-icon">✨</div>
|
||||||
|
<h3 class="h5 fw-bold">Meaningful Matches</h3>
|
||||||
|
<p class="text-muted mb-0">Search by course, year, and what you're looking for to find the perfect match.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
79
core/templates/core/login.html
Normal file
79
core/templates/core/login.html
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Log In | Warwick Connect{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
<style>
|
||||||
|
.auth-card {
|
||||||
|
max-width: 450px;
|
||||||
|
margin: 4rem auto;
|
||||||
|
padding: 3rem;
|
||||||
|
background: white;
|
||||||
|
border-radius: 24px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus {
|
||||||
|
border-color: var(--warwick-navy);
|
||||||
|
box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-title {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-subtitle {
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
padding: 0.8rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="auth-card">
|
||||||
|
<h1 class="auth-title">Log In</h1>
|
||||||
|
<p class="auth-subtitle">Welcome back, student.</p>
|
||||||
|
|
||||||
|
<form method="post" novalidate>
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% for field in form %}
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
|
||||||
|
{{ field }}
|
||||||
|
{% if field.errors %}
|
||||||
|
<div class="text-danger small mt-1">
|
||||||
|
{{ field.errors.0 }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary btn-submit w-100">Sign In</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p class="mt-4 text-center text-muted small">
|
||||||
|
New to Warwick Connect? <a href="{% url 'register' %}" class="text-decoration-none fw-bold">Join Now</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
108
core/templates/core/profile_edit.html
Normal file
108
core/templates/core/profile_edit.html
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Complete Your Profile | Warwick Connect{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
<style>
|
||||||
|
.profile-card {
|
||||||
|
max-width: 650px;
|
||||||
|
margin: 2rem auto;
|
||||||
|
padding: 3rem;
|
||||||
|
background: white;
|
||||||
|
border-radius: 24px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control, .form-select {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus, .form-select:focus {
|
||||||
|
border-color: var(--warwick-navy);
|
||||||
|
box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-title {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 2.25rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-subtitle {
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit {
|
||||||
|
margin-top: 2rem;
|
||||||
|
padding: 1rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
color: var(--text-dark);
|
||||||
|
border-bottom: 2px solid var(--bg-light);
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="profile-card">
|
||||||
|
<h1 class="profile-title">Complete Your Profile</h1>
|
||||||
|
<p class="profile-subtitle">Tell other students about yourself to find better connections.</p>
|
||||||
|
|
||||||
|
<form method="post" novalidate>
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h3 class="section-title">Academic & Location</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="{{ form.course.id_for_label }}" class="form-label">Course</label>
|
||||||
|
{{ form.course }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="{{ form.year.id_for_label }}" class="form-label">Year of Study</label>
|
||||||
|
{{ form.year }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="{{ form.location.id_for_label }}" class="form-label">Location</label>
|
||||||
|
{{ form.location }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="{{ form.looking_for.id_for_label }}" class="form-label">Looking For</label>
|
||||||
|
{{ form.looking_for }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mt-4">
|
||||||
|
<h3 class="section-title">About You</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<label for="{{ form.bio.id_for_label }}" class="form-label">Bio (Optional)</label>
|
||||||
|
{{ form.bio }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary btn-submit w-100 mt-5">Save and Discover Students</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
82
core/templates/core/register.html
Normal file
82
core/templates/core/register.html
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Join Warwick Connect{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
<style>
|
||||||
|
.auth-card {
|
||||||
|
max-width: 450px;
|
||||||
|
margin: 4rem auto;
|
||||||
|
padding: 3rem;
|
||||||
|
background: white;
|
||||||
|
border-radius: 24px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus {
|
||||||
|
border-color: var(--warwick-navy);
|
||||||
|
box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-title {
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--warwick-navy);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-subtitle {
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
padding: 0.8rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="auth-card">
|
||||||
|
<h1 class="auth-title">Create Account</h1>
|
||||||
|
<p class="auth-subtitle">Join the exclusive Warwick student network.</p>
|
||||||
|
|
||||||
|
<form method="post" novalidate>
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% for field in form %}
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
|
||||||
|
{{ field }}
|
||||||
|
{% if field.help_text %}
|
||||||
|
<div class="form-text">{{ field.help_text }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if field.errors %}
|
||||||
|
<div class="text-danger small mt-1">
|
||||||
|
{{ field.errors.0 }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary btn-submit w-100">Create Account</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p class="mt-4 text-center text-muted small">
|
||||||
|
Already have an account? <a href="{% url 'login' %}" class="text-decoration-none fw-bold">Log In</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
12
core/urls.py
12
core/urls.py
@ -1,7 +1,11 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
from .views import home
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", home, name="home"),
|
path('', views.home, name='home'),
|
||||||
]
|
path('register/', views.register, name='register'),
|
||||||
|
path('login/', views.login_view, name='login'),
|
||||||
|
path('logout/', views.logout_view, name='logout'),
|
||||||
|
path('dashboard/', views.dashboard, name='dashboard'),
|
||||||
|
path('profile/edit/', views.profile_edit, name='profile_edit'),
|
||||||
|
]
|
||||||
117
core/views.py
117
core/views.py
@ -1,25 +1,110 @@
|
|||||||
import os
|
import os
|
||||||
import platform
|
import random
|
||||||
|
|
||||||
from django import get_version as django_version
|
from django import get_version as django_version
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from django.contrib.auth import login, authenticate, logout
|
||||||
|
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib import messages
|
||||||
|
from django import forms
|
||||||
|
from .models import Profile, Photo
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
class WarwickRegistrationForm(UserCreationForm):
|
||||||
|
email = forms.EmailField(required=True, help_text="Enter your @warwick.ac.uk email address")
|
||||||
|
|
||||||
|
def clean_email(self):
|
||||||
|
email = self.cleaned_data.get('email')
|
||||||
|
if not email.endswith("@warwick.ac.uk"):
|
||||||
|
raise forms.ValidationError("You must use a @warwick.ac.uk email address to register.")
|
||||||
|
if User.objects.filter(email=email).exists():
|
||||||
|
raise forms.ValidationError("This email is already in use.")
|
||||||
|
return email
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
user = super().save(commit=False)
|
||||||
|
user.email = self.cleaned_data['email']
|
||||||
|
if commit:
|
||||||
|
user.save()
|
||||||
|
return user
|
||||||
|
|
||||||
|
class ProfileEditForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Profile
|
||||||
|
fields = ['course', 'year', 'location', 'looking_for', 'bio']
|
||||||
|
widgets = {
|
||||||
|
'course': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'e.g. Computer Science'}),
|
||||||
|
'year': forms.Select(attrs={'class': 'form-select'}),
|
||||||
|
'location': forms.Select(attrs={'class': 'form-select'}),
|
||||||
|
'looking_for': forms.Select(attrs={'class': 'form-select'}),
|
||||||
|
'bio': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'placeholder': 'Tell others a bit about yourself...'}),
|
||||||
|
}
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
"""Render the landing screen with loader and environment details."""
|
if request.user.is_authenticated:
|
||||||
host_name = request.get_host().lower()
|
return redirect('dashboard')
|
||||||
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
|
return render(request, "core/index.html")
|
||||||
now = timezone.now()
|
|
||||||
|
def register(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = WarwickRegistrationForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
user = form.save()
|
||||||
|
login(request, user)
|
||||||
|
messages.success(request, "Welcome to Warwick Connect! Please complete your profile.")
|
||||||
|
return redirect('profile_edit')
|
||||||
|
else:
|
||||||
|
form = WarwickRegistrationForm()
|
||||||
|
return render(request, 'core/register.html', {'form': form})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def profile_edit(request):
|
||||||
|
profile = request.user.profile
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = ProfileEditForm(request.POST, instance=profile)
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
messages.success(request, "Profile updated successfully!")
|
||||||
|
return redirect('dashboard')
|
||||||
|
else:
|
||||||
|
form = ProfileEditForm(instance=profile)
|
||||||
|
return render(request, 'core/profile_edit.html', {'form': form, 'profile': profile})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def dashboard(request):
|
||||||
|
all_profiles = Profile.objects.exclude(user=request.user)
|
||||||
|
|
||||||
|
if not request.user.profile.is_subscribed:
|
||||||
|
profiles_list = list(all_profiles)
|
||||||
|
if len(profiles_list) > 12:
|
||||||
|
visible_profiles = random.sample(profiles_list, 12)
|
||||||
|
locked_profiles = [p for p in profiles_list if p not in visible_profiles]
|
||||||
|
else:
|
||||||
|
visible_profiles = profiles_list
|
||||||
|
locked_profiles = []
|
||||||
|
else:
|
||||||
|
visible_profiles = all_profiles
|
||||||
|
locked_profiles = []
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"project_name": "New Style",
|
'visible_profiles': visible_profiles,
|
||||||
"agent_brand": agent_brand,
|
'locked_profiles': locked_profiles,
|
||||||
"django_version": django_version(),
|
'is_subscribed': request.user.profile.is_subscribed,
|
||||||
"python_version": platform.python_version(),
|
|
||||||
"current_time": now,
|
|
||||||
"host_name": host_name,
|
|
||||||
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
|
|
||||||
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
|
||||||
}
|
}
|
||||||
return render(request, "core/index.html", context)
|
return render(request, 'core/dashboard.html', context)
|
||||||
|
|
||||||
|
def login_view(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = AuthenticationForm(request, data=request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
user = form.get_user()
|
||||||
|
login(request, user)
|
||||||
|
return redirect('dashboard')
|
||||||
|
else:
|
||||||
|
form = AuthenticationForm()
|
||||||
|
return render(request, 'core/login.html', {'form': form})
|
||||||
|
|
||||||
|
def logout_view(request):
|
||||||
|
logout(request)
|
||||||
|
return redirect('home')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user