diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 74d4e51c..63cdcbc9 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc index 8675bb1d..0be67e87 100644 Binary files a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc index ac762040..1127e532 100644 Binary files a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index 5c60a206..453de335 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/admin.py b/osinaweb/osinacore/admin.py index 034f32ae..9f1a1161 100644 --- a/osinaweb/osinacore/admin.py +++ b/osinaweb/osinacore/admin.py @@ -29,5 +29,5 @@ admin.site.register(Project, ProjectAdmin) admin.site.register(Milestone) admin.site.register(Epic) admin.site.register(Note) - +admin.site.register(Task) diff --git a/osinaweb/osinacore/migrations/0020_task.py b/osinaweb/osinacore/migrations/0020_task.py new file mode 100644 index 00000000..f692723e --- /dev/null +++ b/osinaweb/osinacore/migrations/0020_task.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.5 on 2023-09-14 14:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0019_alter_epic_end_date_alter_epic_start_date'), + ] + + operations = [ + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=250)), + ('status', models.CharField(choices=[('Open', 'Open'), ('Working On', 'Working On'), ('Closed', 'Closed')], max_length=200, null=True)), + ('extra', models.BooleanField(default=False)), + ('description', models.TextField()), + ('start_date', models.CharField(max_length=200)), + ('end_date', models.CharField(max_length=200)), + ('epic', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='osinacore.epic')), + ('project', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='osinacore.project')), + ], + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0020_task.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0020_task.cpython-310.pyc new file mode 100644 index 00000000..d145d613 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0020_task.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index a136f81a..08bdc19a 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -158,3 +158,21 @@ class Note(models.Model): date = models.DateTimeField(null=True,blank=True) user = models.ForeignKey(User, on_delete=models.CASCADE, null=True,blank=True) color = ColorField(default='#FF0000',blank=True) + + +class Task(models.Model): + name = models.CharField(max_length=250) + project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True) + epic = models.ForeignKey(Epic, on_delete=models.CASCADE, null=True) + STATUS_CHOICES = ( + ('Open', 'Open'), + ('Working On', 'Working On'), + ('Closed', 'Closed') + ) + status = models.CharField(max_length=200, choices=STATUS_CHOICES, null=True) + extra = models.BooleanField(default=False) + description = models.TextField() + start_date = models.CharField(max_length=200) + end_date = models.CharField(max_length=200) + + \ No newline at end of file diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 37723c6a..d4f607f7 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -101,9 +101,11 @@ def detailed_project(request, project_id): @login_required def createtask_project(request, project_id): project = get_object_or_404(Project, project_id=project_id) + epics_of_my_project = Epic.objects.filter(project=project) context = { 'project' : project, + 'epics_of_my_project' : epics_of_my_project, } return render(request, 'createtask-project.html', context) @@ -127,8 +129,10 @@ def create_project(request): @login_required def create_epic(request, project_id): project = get_object_or_404(Project, project_id=project_id) + context = { 'project' : project, + } return render(request, 'create-epic.html', context) @@ -328,3 +332,49 @@ def save_epic(request): # Redirect to the detailed project page redirect_url = reverse('detailed-project', args=[project.project_id]) return redirect(redirect_url) + + +@login_required +def save_task(request): + if request.method == 'POST': + name = request.POST.get('name') + status = request.POST.get('status') + project_id = request.POST.get('project') + epic_id = request.POST.get('epic') + extra = request.POST.get('extra') + description = request.POST.get('description') + start_date = request.POST.get('start_date') + end_date = request.POST.get('end_date') + + try: + project = Project.objects.get(id=project_id) + except Project.DoesNotExist: + # Handle the case where the project with the provided ID doesn't exist + # You might want to display an error message or redirect to an appropriate page. + pass + + try: + epic = Epic.objects.get(id=epic_id) + except Epic.DoesNotExist: + # Handle the case where the epic with the provided ID doesn't exist + # You might want to display an error message or redirect to an appropriate page. + pass + + # Create the Task object with the Project and Epic instances + task = Task( + name=name, + status=status, + project=project, + epic=epic, + extra=extra, + description=description, + start_date=start_date, + end_date=end_date + ) + + # Save the Task object to the database + task.save() + + # Redirect to the detailed project page + redirect_url = reverse('detailed-project', args=[project.project_id]) + return redirect(redirect_url) \ No newline at end of file diff --git a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc index 9050fd04..f54119c6 100644 Binary files a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinaweb/urls.py b/osinaweb/osinaweb/urls.py index f24600d7..7ea1fb95 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -19,7 +19,6 @@ from osinacore import views from django.contrib.auth.decorators import login_required urlpatterns = [ - # Pages urls path('admin/', admin.site.urls), path('login', views.signin, name='signin'), @@ -51,4 +50,5 @@ urlpatterns = [ path('save_note/', views.save_note, name='save_note'), path('save_project/', views.save_project, name='save_project'), path('save_epic/', views.save_epic, name='save_epic'), + path('save_task/', views.save_task, name='save_task'), ] diff --git a/osinaweb/templates/create-epic.html b/osinaweb/templates/create-epic.html index 8563bb5d..78eb42ee 100644 --- a/osinaweb/templates/create-epic.html +++ b/osinaweb/templates/create-epic.html @@ -5,7 +5,7 @@