-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Django-Projects-Ls/main
Main
- Loading branch information
Showing
14 changed files
with
373 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# SchoolSchedules | ||
# SchoolSchedules | ||
|
||
## Setup Virtual Environment (venv) | ||
|
||
### Linux | ||
|
||
These commands bellow are creating a folder .venv and activate the environment in the terminal. | ||
|
||
```bash | ||
python3 manage.py venv .venv | ||
source .venv/bin/activate | ||
``` | ||
|
||
### Windows | ||
|
||
```bash | ||
py manage.py venv .venv | ||
.venv/Scripts/activate | ||
``` | ||
|
||
## Installing Dependencies (requirements.txt) | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Running server | ||
|
||
```bash | ||
python3 manage.py runserver | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from django.contrib import admin | ||
from .models import Disciplina, Curso, Horario | ||
|
||
# Register your models here. | ||
for model in [Disciplina, Curso, Horario]: | ||
admin.site.register(model) | ||
for model in [ | ||
Disciplina, | ||
Curso, | ||
Horario, | ||
]: | ||
admin.site.register(model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
from django.db.models import ManyToManyField | ||
|
||
def get_field_values(instance): | ||
field_values = {} | ||
fields = instance._meta.get_fields(include_hidden=True) | ||
field_values = {} | ||
fields = instance._meta.get_fields(include_hidden=True) | ||
|
||
for field in fields: | ||
try: | ||
if isinstance(field, ManyToManyField): | ||
# If the field is a many-to-many field, get all related objects | ||
related_objects = getattr(instance, field.name).all() | ||
field_values[field.name] = ", ".join( | ||
str(obj) for obj in related_objects | ||
) | ||
continue | ||
for field in fields: | ||
try: | ||
if isinstance(field, ManyToManyField): | ||
# If the field is a many-to-many field, get all related objects | ||
related_objects = getattr(instance, field.name).all() | ||
field_values[field.name] = ", ".join( | ||
str(obj) for obj in related_objects | ||
) | ||
continue | ||
|
||
field_values[field.name] = getattr(instance, field.name) | ||
field_values[field.name] = getattr(instance, field.name) | ||
|
||
except Exception: | ||
pass | ||
except Exception: | ||
pass | ||
|
||
return field_values | ||
return field_values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
<!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> | ||
{% extends "home.html" %} | ||
|
||
{% block title %} <title>{{ object_type | capfirst }} | Delete</title> {% endblock %} | ||
|
||
{% block content %} | ||
<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> | ||
{% include 'partials/form_component.html' with value="Yes, i'm sure" delete=true %} | ||
{% endblock %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="pt-br"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>{% if object_type %} {{ object_type | capfirst }} | Update {% else %} Create {% endif %}</title> | ||
</head> | ||
<body> | ||
{% extends 'home.html' %} | ||
|
||
{% block title %} | ||
<title> | ||
{% if object_type %} | ||
{{ object_type | capfirst }} | Update | ||
{% else %} | ||
Create | ||
{% endif %} | ||
</title> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% 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> | ||
{% include 'partials/form_component.html' with value="Save" %} | ||
|
||
<a href="{{request.META.HTTP_REFERER}}">Back</a> | ||
</body> | ||
</html> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="pt-br"> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Home page</title> | ||
{% block title %} <title>Home page</title> {% endblock %} | ||
</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> | ||
{% block content%} | ||
<a href="list-courses"><p>Courses</p></a> | ||
<a href="list-disciplines"><p>Disciplines</p></a> | ||
<a href="list-schedules"><p>Schedules</p></a> | ||
{% endblock %} | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
<!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> | ||
{% extends 'home.html' %} | ||
|
||
{% block title %} <title>{{ object_type | title }} | List</title> {% endblock %} | ||
|
||
{% block content %} | ||
<h1>{{ object_type | title }} | List</h1> | ||
|
||
{% for object in objects %} | ||
<a href="{{ object.get_absolute_url }}"><p>{{ object }}</p></a> | ||
{% endfor %} | ||
|
||
<button onclick="location.href = 'create'">Adicionar {{ object_type }}</button> | ||
<a href="/">Back</a> | ||
</body> | ||
</html> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
{% if not delete %} | ||
{{ form.as_p }} | ||
{% endif %} | ||
|
||
<input type="submit" value="{{ value }}"> | ||
</form> |
Oops, something went wrong.