Skip to content

Commit

Permalink
Merge pull request #3 from Django-Projects-Ls/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
LopesLs authored Dec 24, 2023
2 parents fb1a333 + 9dd8677 commit 73b9b16
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 99 deletions.
17 changes: 17 additions & 0 deletions scheduleManagement/extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db.models import ManyToManyField

def get_field_values(instance):
field_values = {}
fields = instance._meta.get_fields(include_hidden=True)

for field in fields:
try:
if isinstance(field, ManyToManyField):
related_objects = getattr(instance, field.name).all()
field_values[field.name] = ', '.join(str(obj) for obj in related_objects)
else:
field_values[field.name] = getattr(instance, field.name)
except Exception:
pass

return field_values
7 changes: 0 additions & 7 deletions scheduleManagement/forms.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2023-12-24 13:44

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scheduleManagement', '0001_initial'),
]

operations = [
migrations.RenameField(
model_name='horario',
old_name='horarioInicio',
new_name='hora_fim',
),
migrations.RenameField(
model_name='horario',
old_name='horarioTermino',
new_name='hora_inicio',
),
]
6 changes: 3 additions & 3 deletions scheduleManagement/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

class Horario(models.Model):
dia = models.DateField()
horarioInicio = models.TimeField()
horarioTermino = models.TimeField()
hora_inicio = models.TimeField()
hora_fim = models.TimeField()

def __str__(self):
return f'{self.dia} | {self.horarioInicio} - {self.horarioTermino}'
return f'{self.dia} | {self.hora_inicio} - {self.hora_fim}'

class Disciplina(models.Model):
nome = models.CharField(max_length=255)
Expand Down
17 changes: 17 additions & 0 deletions scheduleManagement/templates/confirm-delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ object_type | capfirst }} | Delete</title>
</head>
<body>
<h1>{{ object_type | capfirst }} | Delete</h1>

<p>Are you sure you want to delete <strong>{{ object }}?</strong></p>

<form method="post">
{% csrf_token %}
<input type="submit" value="Yes, I'm sure">
</body>
</html>
16 changes: 0 additions & 16 deletions scheduleManagement/templates/course.html

This file was deleted.

18 changes: 0 additions & 18 deletions scheduleManagement/templates/details.html

This file was deleted.

22 changes: 22 additions & 0 deletions scheduleManagement/templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ object_type | capfirst }} | Update</title>
</head>
<body>
{% if object_type %}
<h1>{{ object_type | capfirst }} | Update</h1>
{% else %}
<h1>Create</h1>
{% endif %}

<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save">
</form>
<a href="{{request.META.HTTP_REFERER}}">Back</a>
</body>
</html>
13 changes: 13 additions & 0 deletions scheduleManagement/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home page</title>
</head>
<body>
<a href="list-courses"><p>Courses</p></a>
<a href="list-disciplines"><p>Disciplines</p></a>
<a href="list-schedules"><p>Schedules</p></a>
</body>
</html>
15 changes: 0 additions & 15 deletions scheduleManagement/templates/index.html

This file was deleted.

16 changes: 16 additions & 0 deletions scheduleManagement/templates/list-object.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ object_type | capfirst }} | List</title>
</head>
<body>
<h1>{{ object_type | capfirst }} | List</h1>
{% for object in objects %}
<a href="{{ object.id }}"><p>{{ object }}</p></a>
{% endfor %}
<button onclick="location.href = 'create'">Adicionar {{ object_type }}</button>
<a href="/">Back</a>
</body>
</html>
20 changes: 20 additions & 0 deletions scheduleManagement/templates/object-details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ object_type | capfirst }} | Details</title>
</head>
<body>
<h1> {{ object_type | capfirst }} | Details</h1>
{% for field, value in object.items %}
<ul>
<li>{{ field }}: {{ value }}</li>
</ul>
{% endfor %}

<button onclick="location.href = 'edit/{{ object.id }}'" >Update</button>
<button onclick="location.href = 'delete/{{ object.id }}'" >Delete</button>
<a href="/list-{{ object_type }}s">Back</a>
</body>
</html>
25 changes: 19 additions & 6 deletions scheduleManagement/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
from django.urls import path
from . import views
from django.views.generic import TemplateView

urlpatterns = [
path('', views.MainRequestHandler.as_view(), name='home'),

path('disciplina/<int:disciplina_id>', views.DisciplinaRequestHandler.as_view(), name='disciplina_details'),
path('', TemplateView.as_view(template_name='home.html'), name='home'),

path('list-courses/', views.CourseListRequestHandler.as_view(), name='list_courses'),
path('list-courses/create/', views.CourseCreateRequestHandler.as_view(), name='create_course'),
path('list-courses/<int:pk>', views.CourseDetailsRequestHandler.as_view(), name='detail_course'),
path('list-courses/edit/<int:pk>', views.CourseUpdateRequestHandler.as_view(), name='edit_course'),
path('list-courses/delete/<int:pk>', views.CourseDeleteRequestHandler.as_view(), name='delete_course'),

path('add-course/', views.CourseAddRequestHandler.as_view(), name='add_course'),
path('details/<int:curso_id>', views.DetailsRequestHandler.as_view(), name='curso_details'),
path('edit-course/<int:curso_id>', views.CourseEditRquestHandler.as_view(), name='edit_course'),
path('list-disciplines/', views.DisciplineListRequestHandler.as_view(), name='list_disciplines'),
path('list-disciplines/create/', views.DisciplineCreateRequestHandler.as_view(), name='create_discipline'),
path('list-disciplines/<int:pk>', views.DisciplineDetailsRequestHandler.as_view(), name='detail_discipline'),
path('list-disciplines/edit/<int:pk>', views.DisciplineUpdateRequestHandler.as_view(), name='edit_discipline'),
path('list-disciplines/delete/<int:pk>', views.DisciplineDeleteRequestHandler.as_view(), name='delete_discipline'),

path('list-schedules/', views.ScheduleListRequestHandler.as_view(), name='list_schedules'),
path('list-schedules/create/', views.ScheduleCreateRequestHandler.as_view(), name='create_schedule'),
path('list-schedules/<int:pk>', views.ScheduleDetailsRequestHandler.as_view(), name='detail_schedule'),
path('list-schedules/edit/<int:pk>', views.ScheduleUpdateRequestHandler.as_view(), name='edit_schedule'),
path('list-schedules/delete/<int:pk>', views.ScheduleDeleteRequestHandler.as_view(), name='delete_schedule'),
]
Loading

0 comments on commit 73b9b16

Please sign in to comment.