diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..67bf7ac 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 5a69659..9977bb1 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2a36fd6..a0a46b2 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..b2f6248 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 5.2.7 on 2026-01-21 23:10 + +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')), + ('referral_code', models.CharField(blank=True, max_length=20, unique=True)), + ('points', models.IntegerField(default=0)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..9230c4f Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..3b991e3 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,28 @@ 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 +import uuid -# Create your models here. +class Profile(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile') + referral_code = models.CharField(max_length=20, unique=True, blank=True) + points = models.IntegerField(default=0) + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.user.username}'s Profile" + + def save(self, *args, **kwargs): + if not self.referral_code: + self.referral_code = str(uuid.uuid4()).replace('-', '')[:8].upper() + super().save(*args, **kwargs) + +@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() \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..4928a2e 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,9 +1,10 @@ - +{% load static %} - {% block title %}Knowledge Base{% endblock %} + + {% block title %}Referral Rewards{% endblock %} {% if project_description %} @@ -13,13 +14,121 @@ {% endif %} - {% load static %} + + + + + + + + + + {% block head %}{% endblock %} - {% block content %}{% endblock %} - + - +
+ {% if messages %} +
+ {% for message in messages %} + + {% endfor %} +
+ {% endif %} + + {% block content %}{% endblock %} +
+ + + + + + {% block scripts %}{% endblock %} + + \ No newline at end of file diff --git a/core/templates/core/dashboard.html b/core/templates/core/dashboard.html new file mode 100644 index 0000000..874c0c3 --- /dev/null +++ b/core/templates/core/dashboard.html @@ -0,0 +1,118 @@ +{% extends 'base.html' %} + +{% block title %}Dashboard - Referral Rewards{% endblock %} + +{% block content %} +
+
+ +
+
+
+
+ {{ user.username|first|upper }} +
+
+

Hello, {{ user.username }}!

+

Track your progress and share your rewards.

+
+
+
+
+ + +
+
+

Total Points

+

{{ profile.points }}

+

Points to next reward: 100

+
+
+
+
+
+ + +
+
+

Your Referral Link

+

Share this code with your friends and earn points when they sign up!

+ +
+ + +
+ +
+ + +
+
+
+ + +
+
+
+

Marketing Collateral

+

Assets to help you promote your referral code.

+
+ +
+
+
+
+
+ Social Media Banner 1 +
+
+ +
+
+
+
+
+
+ Email Signature +
+
+ +
+
+
+
+
+
+ Instagram Story Template +
+
+ +
+
+
+
+
+
+
+ + +{% endblock %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html index faec813..1aa9d0f 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -1,145 +1,95 @@ -{% extends "base.html" %} - -{% block title %}{{ project_name }}{% endblock %} - -{% block head %} - - - - -{% endblock %} +{% extends 'base.html' %} +{% load static %} {% block content %} -
-
-

Analyzing your requirements and generating your app…

-
- Loading… +
+
+
+
+

Turn Friendships into Rewards

+

Share the love and get rewarded for every friend you refer. It's simple, fast, and completely free to join.

+ +
+
+
+
+
+ + + + +
+

Referral Success!

+
+

"I just invited 5 friends and earned 500 points toward my next purchase. It was so easy!"

+
+
+
+ Alex Johnson +
+ +500 pts +
+
+
+
-

AppWizzy AI is collecting your requirements and applying the first changes.

-

This page will refresh automatically as the plan is implemented.

-

- Runtime: Django {{ django_version }} · Python {{ python_version }} - — UTC {{ current_time|date:"Y-m-d H:i:s" }} -

-
-
- -{% endblock %} \ No newline at end of file + + +
+ + + +
+ + +
+
+
+

How it Works

+

Get started in minutes and begin your journey toward amazing rewards.

+
+
+
+
+
+ 1 +
+

Create Account

+

Sign up in seconds. You'll instantly get a unique referral code to share with your network.

+
+
+
+
+
+ 2 +
+

Share Code

+

Send your code to friends or share it on social media. Use our marketing collateral to stand out.

+
+
+
+
+
+ 3 +
+

Get Rewards

+

Watch your points grow every time someone signs up using your code. Redeem points for exclusive perks.

+
+
+
+
+
+ +
+
+
+

Ready to start earning?

+

Join thousands of customers who are already getting rewarded for their loyalty.

+ Sign Up for Free +
+
+
+{% endblock %} diff --git a/core/templates/core/login.html b/core/templates/core/login.html new file mode 100644 index 0000000..a9e978a --- /dev/null +++ b/core/templates/core/login.html @@ -0,0 +1,45 @@ +{% extends 'base.html' %} + +{% block title %}Login - Referral Rewards{% endblock %} + +{% block content %} +
+
+
+
+
+

Welcome Back

+

Login to manage your referrals.

+
+ +
+ {% csrf_token %} + {% if form.non_field_errors %} +
+ {% for error in form.non_field_errors %} + {{ error }} + {% endfor %} +
+ {% endif %} + +
+ + +
+ +
+ + +
+ + +
+ +
+

Don't have an account? Sign Up

+
+
+
+
+
+{% endblock %} diff --git a/core/templates/core/signup.html b/core/templates/core/signup.html new file mode 100644 index 0000000..4c4fd28 --- /dev/null +++ b/core/templates/core/signup.html @@ -0,0 +1,42 @@ +{% extends 'base.html' %} + +{% block title %}Join Referral Rewards{% endblock %} + +{% block content %} +
+
+
+
+
+

Create Your Account

+

Start earning rewards today.

+
+ +
+ {% csrf_token %} + {% for field in form %} +
+ + {{ field.errors }} + + {% if field.help_text %} +
{{ field.help_text|safe }}
+ {% endif %} +
+ {% endfor %} + + +
+ +
+

Already have an account? Log In

+
+
+
+
+
+{% endblock %} diff --git a/core/urls.py b/core/urls.py index 6299e3d..8493052 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,7 +1,11 @@ from django.urls import path - -from .views import home +from django.contrib.auth import views as auth_views +from . import views urlpatterns = [ - path("", home, name="home"), -] + path("", views.home, name="home"), + path("signup/", views.signup, name="signup"), + path("dashboard/", views.dashboard, name="dashboard"), + path("login/", auth_views.LoginView.as_view(template_name='core/login.html'), name="login"), + path("logout/", views.logout_view, name="logout"), +] \ No newline at end of file diff --git a/core/views.py b/core/views.py index c9aed12..4afd890 100644 --- a/core/views.py +++ b/core/views.py @@ -1,25 +1,34 @@ -import os -import platform - -from django import get_version as django_version -from django.shortcuts import render -from django.utils import timezone - +from django.shortcuts import render, redirect +from django.contrib.auth import login, logout +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.decorators import login_required +from django.contrib import messages +from .models import Profile def home(request): - """Render the landing screen with loader and environment details.""" - host_name = request.get_host().lower() - agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic" - now = timezone.now() + if request.user.is_authenticated: + return redirect('dashboard') + return render(request, 'core/index.html') - context = { - "project_name": "New Style", - "agent_brand": agent_brand, - "django_version": django_version(), - "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) +def signup(request): + if request.user.is_authenticated: + return redirect('dashboard') + if request.method == 'POST': + form = UserCreationForm(request.POST) + if form.is_valid(): + user = form.save() + login(request, user) + messages.success(request, "Welcome to Referral Rewards! Your account has been created.") + return redirect('dashboard') + else: + form = UserCreationForm() + return render(request, 'core/signup.html', {'form': form}) + +@login_required +def dashboard(request): + profile = request.user.profile + return render(request, 'core/dashboard.html', {'profile': profile}) + +def logout_view(request): + logout(request) + return redirect('home') \ No newline at end of file