Skip to content

Commit

Permalink
feat: Finish first version (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Feb 21, 2024
1 parent 7f5c6c0 commit 94ff7ae
Show file tree
Hide file tree
Showing 47 changed files with 816 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ groups:
CWD=$(pwd)
CMD_FLAG="{{ '--check' if args.check else '' }} --no-input"
for app in 'sites' 'growth_plan_linker' ''; do
for app in 'sites' 'growth_plan_linker' 'projects' 'linker' ''; do
echo -e "\nMaking migration files for: '${app}' ...\n"
CMD="python manage.py makemigrations ${CMD_FLAG} ${app}"
sugar run --service app --cmd $CMD
Expand Down
8 changes: 7 additions & 1 deletion src/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@
'drf_spectacular',
]

LOCAL_APPS = ['growth_plan_linker.users', 'growth_plan_linker']
LOCAL_APPS = [
'growth_plan_linker.users',
'growth_plan_linker',
'projects.apps.ProjectsConfig',
'linker.apps.LinkerConfig',
'growth_plan.apps.GrowthPlanConfig',
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

Expand Down
8 changes: 7 additions & 1 deletion src/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from drf_spectacular.views import SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token

from growth_plan_linker.urls import (
urlpatterns as urlpatterns_growth_plan_linker,
)


urlpatterns = [
path(
'', TemplateView.as_view(template_name='pages/home.html'), name='home'
Expand All @@ -31,7 +36,8 @@
# ...
# Media files
*static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT),
]
] + urlpatterns_growth_plan_linker

if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
urlpatterns += staticfiles_urlpatterns()
Expand Down
Empty file added src/growth_plan/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/growth_plan/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Register your models here.
6 changes: 6 additions & 0 deletions src/growth_plan/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GrowthPlanConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'growth_plan'
31 changes: 31 additions & 0 deletions src/growth_plan/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django import forms

from .models import GrowthPlanItem


class GrowthPlanItemForm(forms.ModelForm):
class Meta:
model = GrowthPlanItem
fields = [
'title',
'description',
'start_date',
'end_date',
'progress_percentage',
]
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control'}),
'description': forms.Textarea(attrs={'class': 'form-control'}),
# Specify the date format for start_date and end_date fields
'start_date': forms.DateInput(
format='%Y-%m-%d',
attrs={'class': 'form-control', 'type': 'date'},
),
'end_date': forms.DateInput(
format='%Y-%m-%d',
attrs={'class': 'form-control', 'type': 'date'},
),
'progress_percentage': forms.NumberInput(
attrs={'class': 'form-control'}
),
}
33 changes: 33 additions & 0 deletions src/growth_plan/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.0.2 on 2024-02-21 01:59

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='GrowthPlanItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255, verbose_name='Title')),
('description', models.TextField(verbose_name='Description')),
('start_date', models.DateField(verbose_name='Start Date')),
('end_date', models.DateField(verbose_name='End Date')),
('progress_percentage', models.PositiveIntegerField(default=0, help_text='Enter a number between 0 and 100.', verbose_name='Progress Percentage')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='growth_plan_items', to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={
'verbose_name': 'Growth Plan Item',
'verbose_name_plural': 'Growth Plan Items',
},
),
]
Empty file.
28 changes: 28 additions & 0 deletions src/growth_plan/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _


class GrowthPlanItem(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='growth_plan_items',
verbose_name=_('User'),
)
title = models.CharField(max_length=255, verbose_name=_('Title'))
description = models.TextField(verbose_name=_('Description'))
start_date = models.DateField(verbose_name=_('Start Date'))
end_date = models.DateField(verbose_name=_('End Date'))
progress_percentage = models.PositiveIntegerField(
default=0,
verbose_name=_('Progress Percentage'),
help_text=_('Enter a number between 0 and 100.'),
)

class Meta:
verbose_name = _('Growth Plan Item')
verbose_name_plural = _('Growth Plan Items')

def __str__(self):
return self.title
21 changes: 21 additions & 0 deletions src/growth_plan/templates/growth-plan-item-confirm-delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends 'base.html' %}

{% block content %}
<div class="container py-4">
<h2>
Confirm Delete
</h2>
<p>
Are you sure you want to delete "{{ object.title }}"?
</p>
<form method="post">
{% csrf_token %}
<button type="submit"
class="btn btn-danger">
Delete
</button>
<a href="{% url 'user-growth-plan-list' %}"
class="btn btn-secondary">Cancel</a>
</form>
</div>
{% endblock content %}
43 changes: 43 additions & 0 deletions src/growth_plan/templates/growth-plan-item-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% extends 'base.html' %}

{% block content %}
<style>
.invalid-feedback-block {
display: block";

}
</style>
<div class="container py-4">
<h2>
{{ title }} Growth Plan Item
</h2>
<form method="post"
class="needs-validation"
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 %}
<small class="form-text text-muted">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<div class="invalid-feedback invalid-feedback-block">
{{ error }}
</div>
{% endfor %}
</div>
{% endfor %}
<button type="submit"
class="btn btn-success">
Save
</button>
<a href="{% url 'user-growth-plan-list' %}"
class="btn btn-secondary">Back to My Growth Plan</a>
</form>
</div>
{% endblock content %}
45 changes: 45 additions & 0 deletions src/growth_plan/templates/my-growth-plan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends 'base.html' %}

{% block content %}
<div class="container py-4">
<h2>
My Growth Plan
</h2>
<div class="row row-cols-1 row-cols-md-3 g-4">
{% for item in items %}
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">
{{ item.title }}
</h5>
<h6 class="card-subtitle mb-2 text-muted">
{{ item.start_date }} to {{ item.end_date }}
</h6>
<p class="card-text">
{{ item.description }}
</p>
</div>
<div class="card-footer">
<p>
<span class="badge text-bg-primary">
Progress: {{ item.progress_percentage }}%
</span>
</p>
<a href="{% url 'growth-plan-item-edit' item.pk %}"
class="card-link">Edit</a>
<a href="{% url 'growth-plan-item-delete' item.pk %}"
class="card-link">Delete</a>
</div>
</div>
</div>
{% empty %}
<p>
No growth plan items found.
</p>
{% endfor %}
</div>
<a href="{% url 'growth-plan-item-create' %}"
class="btn btn-primary mt-3">Add New Item</a>
</div>
{% endblock content %}
38 changes: 38 additions & 0 deletions src/growth_plan/templates/review-growth-plan-list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends 'base.html' %}

{% block content %}
<div class="container py-4">
<h2>
Growth Plan Review
</h2>
<div class="row">
{% for item in items %}
<div class="col-md-4 mb-3">
<div class="card">
<div class="card-body">
<h5 class="card-title">
{{ item.title }}
</h5>
<h6 class="card-subtitle mb-2 text-muted">
Assigned to: {{ item.user.get_full_name }}
</h6>
<p class="card-text">
{{ item.description }}
</p>
<p>
Progress: {{ item.progress_percentage }}%
</p>
<p>
Duration: {{ item.start_date }} to {{ item.end_date }}
</p>
</div>
</div>
</div>
{% empty %}
<p>
No growth plan items to review.
</p>
{% endfor %}
</div>
</div>
{% endblock content %}
1 change: 1 addition & 0 deletions src/growth_plan/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your tests here.
35 changes: 35 additions & 0 deletions src/growth_plan/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.urls import path

from .views import (
GrowthPlanItemCreateView,
GrowthPlanItemDeleteView,
GrowthPlanItemUpdateView,
review_growth_plan_list,
user_growth_plan_list,
)

urlpatterns = [
path(
'my-growth-plan/', user_growth_plan_list, name='user-growth-plan-list'
),
path(
'review-growth-plans/',
review_growth_plan_list,
name='review-growth-plan-list',
),
path(
'create/',
GrowthPlanItemCreateView.as_view(),
name='growth-plan-item-create',
),
path(
'edit/<int:pk>/',
GrowthPlanItemUpdateView.as_view(),
name='growth-plan-item-edit',
),
path(
'delete/<int:pk>/',
GrowthPlanItemDeleteView.as_view(),
name='growth-plan-item-delete',
),
]
Loading

0 comments on commit 94ff7ae

Please sign in to comment.