-
Analyzing your requirements and generating your app…
-
-
Loading…
+
+
+
+
Welcome to {{ project_name }}
+
Your personal space to reflect and grow.
+
+
+ {% if user.is_authenticated %}
+
+ Log New Mood
+ {% else %}
+
Log In
+ {% endif %}
+
-
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
+
+ {% if user.is_authenticated %}
+
Your Recent Moods
+ {% if mood_entries %}
+
+ {% for entry in mood_entries %}
+
+
+
Mood Score: {{ entry.mood_score }}/5
+ {{ entry.date_time|date:"Y-m-d H:i" }}
+
+
{{ entry.note|truncatewords:30 }}
+ {% if entry.activities.all %}
+
Activities:
+ {% for activity in entry.activities.all %}
+ {{ activity.name }}
+ {% endfor %}
+
+ {% endif %}
+
+ {% endfor %}
+
+ {% else %}
+
You haven't logged any moods yet. Get started!
+ {% endif %}
+ {% else %}
+
+
+
Track Your Mental Wellness
+
Gain insights into your moods and activities to better understand your mental health. Log in to begin your journey.
+
Log In & Get Started
+
+
+ {% endif %}
+
+{% endblock %}
diff --git a/core/templates/core/mood_entry_form.html b/core/templates/core/mood_entry_form.html
new file mode 100644
index 0000000..8893d25
--- /dev/null
+++ b/core/templates/core/mood_entry_form.html
@@ -0,0 +1,57 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/core/urls.py b/core/urls.py
index 6299e3d..8b96229 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -1,7 +1,11 @@
from django.urls import path
-from .views import home
+from .views import home, create_mood_entry, dashboard
+
+app_name = 'core'
urlpatterns = [
- path("", home, name="home"),
-]
+ path("", home, name="index"),
+ path('mood/new/', create_mood_entry, name='create_mood_entry'),
+ path('dashboard/', dashboard, name='dashboard'),
+]
\ No newline at end of file
diff --git a/core/views.py b/core/views.py
index c9aed12..4108665 100644
--- a/core/views.py
+++ b/core/views.py
@@ -2,24 +2,61 @@ import os
import platform
from django import get_version as django_version
-from django.shortcuts import render
+from django.shortcuts import render, redirect
from django.utils import timezone
+from django.contrib.auth.decorators import login_required
+from django.http import JsonResponse
+from .forms import MoodEntryForm
+from .models import MoodEntry
+from django_pandas.io import read_frame
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()
-
+ """Render the home page with mood entries."""
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", ""),
+ 'project_name': "PixelMinds",
}
+ if request.user.is_authenticated:
+ mood_entries = MoodEntry.objects.filter(user=request.user).order_by('-date_time')[:7]
+ context['mood_entries'] = mood_entries
+
return render(request, "core/index.html", context)
+
+
+@login_required
+def dashboard(request):
+ mood_entries = MoodEntry.objects.filter(user=request.user).order_by('date_time')
+ df = read_frame(mood_entries, fieldnames=['date_time', 'mood_score'])
+ df['date_time'] = df['date_time'].dt.strftime('%Y-%m-%d')
+ chart_data = df.to_json(orient='records')
+ return render(request, 'core/dashboard.html', {'chart_data': chart_data})
+
+
+@login_required
+def create_mood_entry(request):
+ if request.method == 'POST':
+ form = MoodEntryForm(request.POST)
+ if form.is_valid():
+ mood_entry = form.save(commit=False)
+ mood_entry.user = request.user
+
+ # Assign color based on mood score
+ mood_score = form.cleaned_data['mood_score']
+ if mood_score == 1:
+ mood_entry.color_code = '#FF0000' # Red
+ elif mood_score == 2:
+ mood_entry.color_code = '#FFC107' # Amber
+ elif mood_score == 3:
+ mood_entry.color_code = '#FFFF00' # Yellow
+ elif mood_score == 4:
+ mood_entry.color_code = '#4CAF50' # Green
+ elif mood_score == 5:
+ mood_entry.color_code = '#2196F3' # Blue
+
+ mood_entry.save()
+ form.save_m2m() # Save the many-to-many relationships
+ return redirect('core:index')
+ else:
+ form = MoodEntryForm()
+
+ return render(request, 'core/mood_entry_form.html', {'form': form})
diff --git a/requirements.txt b/requirements.txt
index e22994c..f3c9ec2 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
Django==5.2.7
mysqlclient==2.2.7
python-dotenv==1.1.1
+django-pandas==0.6.7