diff --git a/cbt/__init__.py b/cbt/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cbt/admin.py b/cbt/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/cbt/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/cbt/apps.py b/cbt/apps.py new file mode 100644 index 0000000..9cac0ad --- /dev/null +++ b/cbt/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CbtConfig(AppConfig): + name = 'cbt' diff --git a/cbt/forms.py b/cbt/forms.py new file mode 100644 index 0000000..653d1a2 --- /dev/null +++ b/cbt/forms.py @@ -0,0 +1,8 @@ +from django.forms import ModelForm + +from .models import ThoughtRecord + +class ThoughtRecordStepOneForm(ModelForm): + class Meta: + model = ThoughtRecord + fields = ["title", "situation"] diff --git a/cbt/models.py b/cbt/models.py new file mode 100644 index 0000000..983cea3 --- /dev/null +++ b/cbt/models.py @@ -0,0 +1,22 @@ +from django.db import models +from django.contrib.auth import get_user_model + +from common.fields import PercentageField + +class EmotionRecord(models.Model): + emotion = models.CharField(max_length=128) + percentage = PercentageField() + description = models.TextField() + +class ThoughtRecord(models.Model): + user = models.ForeignKey(get_user_model(), models.CASCADE) + title = models.CharField(blank=True, null=True, max_length=128) + situation = models.TextField(blank=True, null=True) + emotions = models.ManyToManyField(EmotionRecord) + thoughts = models.TextField(blank=True, null=True) + pro_facts = models.TextField(blank=True, null=True) + con_facts = models.TextField(blank=True, null=True) + realistic = models.TextField(blank=True, null=True) + outcome = models.TextField(blank=True, null=True) + emotions_now = models.ManyToManyField(EmotionRecord, related_name="emotions_now") + complete = models.BooleanField(default=False) \ No newline at end of file diff --git a/cbt/templates/cbt/thoughtrecord1.html b/cbt/templates/cbt/thoughtrecord1.html new file mode 100644 index 0000000..9845f54 --- /dev/null +++ b/cbt/templates/cbt/thoughtrecord1.html @@ -0,0 +1,40 @@ +{% extends "frontend/base.html" %} +{% block "content" %} + +{% if form.errors %} +{% for field in form %} +{% for error in field.errors %} +