generated from FGA0138-MDS-Ajax/template-repository
-
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.
- Loading branch information
Showing
34 changed files
with
254 additions
and
20 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,27 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from .forms import * | ||
from .models import * | ||
|
||
class MembroEquipeAdmin(UserAdmin): | ||
add_form = MembroEquipeCreationForm # Use o formulário de criação personalizado | ||
form = MembroEquipeChangeForm # Formulário de alteração personalizado | ||
model = MembroEquipe | ||
|
||
list_display = ('username', 'fullname', 'email') ## Lista principal na aba users | ||
search_fields = ('username', 'email') | ||
ordering = ('username',) | ||
|
||
## O que aparece quando edita um usuario | ||
fieldsets = ( | ||
(None, {'fields': ('username', 'fullname', 'phone', 'email')}), | ||
) | ||
|
||
## O que aparece quando adiciona um usuario | ||
add_fieldsets = ( | ||
(None, { | ||
'fields': ('username', 'fullname', 'phone', 'email', 'password1', 'password2') | ||
}), | ||
) | ||
|
||
admin.site.register(MembroEquipe, MembroEquipeAdmin) |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
class UsersConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'Users' |
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,12 @@ | ||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm | ||
from .models import * | ||
|
||
class MembroEquipeCreationForm(UserCreationForm): | ||
class Meta: | ||
model = MembroEquipe | ||
fields = ('username', 'fullname', 'email', 'phone', 'password1', 'password2') | ||
|
||
class MembroEquipeChangeForm(UserChangeForm): | ||
class Meta: | ||
model = MembroEquipe | ||
fields = ('username', 'email', 'phone', 'fullname', ) |
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,45 @@ | ||
# Generated by Django 5.1 on 2024-11-23 22:33 | ||
|
||
import django.contrib.auth.models | ||
import django.contrib.auth.validators | ||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('auth', '0012_alter_user_first_name_max_length'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MembroEquipe', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('password', models.CharField(max_length=128, verbose_name='password')), | ||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), | ||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), | ||
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), | ||
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), | ||
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), | ||
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), | ||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), | ||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), | ||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), | ||
('phone', models.CharField(max_length=20)), | ||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), | ||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), | ||
], | ||
options={ | ||
'verbose_name': 'user', | ||
'verbose_name_plural': 'users', | ||
'abstract': False, | ||
}, | ||
managers=[ | ||
('objects', django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
mamutes/Users/migrations/0002_membroequipe_fullname_alter_membroequipe_email.py
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,24 @@ | ||
# Generated by Django 5.1 on 2024-11-23 23:05 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('Users', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='membroequipe', | ||
name='fullname', | ||
field=models.CharField(default='phon', max_length=100), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name='membroequipe', | ||
name='email', | ||
field=models.EmailField(max_length=200), | ||
), | ||
] |
25 changes: 25 additions & 0 deletions
25
mamutes/Users/migrations/0003_membroequipe_area_membroequipe_funcao.py
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,25 @@ | ||
# Generated by Django 5.1 on 2024-11-23 23:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('Users', '0002_membroequipe_fullname_alter_membroequipe_email'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='membroequipe', | ||
name='area', | ||
field=models.CharField(default='a', max_length=100), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='membroequipe', | ||
name='funcao', | ||
field=models.CharField(default='a', max_length=100), | ||
preserve_default=False, | ||
), | ||
] |
21 changes: 21 additions & 0 deletions
21
mamutes/Users/migrations/0004_remove_membroequipe_area_remove_membroequipe_funcao.py
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,21 @@ | ||
# Generated by Django 5.1 on 2024-11-23 23:39 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('Users', '0003_membroequipe_area_membroequipe_funcao'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='membroequipe', | ||
name='area', | ||
), | ||
migrations.RemoveField( | ||
model_name='membroequipe', | ||
name='funcao', | ||
), | ||
] |
37 changes: 37 additions & 0 deletions
37
mamutes/Users/migrations/0005_area_function_membroequipe_areas_and_more.py
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,37 @@ | ||
# Generated by Django 5.1 on 2024-11-24 00:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('Users', '0004_remove_membroequipe_area_remove_membroequipe_funcao'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Area', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Function', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='membroequipe', | ||
name='areas', | ||
field=models.ManyToManyField(blank=True, related_name='membros', to='Users.area'), | ||
), | ||
migrations.AddField( | ||
model_name='membroequipe', | ||
name='functions', | ||
field=models.ManyToManyField(blank=True, related_name='membros', to='Users.function'), | ||
), | ||
] |
Empty file.
Binary file not shown.
Binary file added
BIN
+989 Bytes
...igrations/__pycache__/0002_membroequipe_fullname_alter_membroequipe_email.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+970 Bytes
...s/Users/migrations/__pycache__/0003_membroequipe_area_membroequipe_funcao.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+766 Bytes
...ions/__pycache__/0004_remove_membroequipe_area_remove_membroequipe_funcao.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+1.53 KB
...ers/migrations/__pycache__/0005_area_function_membroequipe_areas_and_more.cpython-312.pyc
Binary file not shown.
Binary file not shown.
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,26 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import AbstractUser | ||
|
||
class Area(models.Model): | ||
name = models.CharField(max_length=100) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
class Function(models.Model): | ||
name = models.CharField(max_length=100) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
class MembroEquipe(AbstractUser): | ||
fullname = models.CharField(max_length=100, blank=False, null=False) | ||
email = models.EmailField (max_length=200, blank=False, null=False) | ||
phone = models.CharField(max_length=20, blank=False, null=False) | ||
|
||
areas = models.ManyToManyField(Area, related_name='membros', blank=True) | ||
functions = models.ManyToManyField(Function, related_name='membros', blank=True) | ||
|
||
def __str__(self): | ||
return self.phone | ||
|
Empty file.
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,23 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from django.shortcuts import render | ||
from django.contrib.auth import authenticate, login as login_django | ||
from .models import * | ||
from .forms import * | ||
|
||
def login (request): | ||
if request.method == 'GET': | ||
return render (request, 'cadastro/login.html') | ||
else: | ||
username = request.POST.get('username') | ||
senha = request.POST.get('senha') | ||
|
||
user = authenticate(username=username, password=senha) | ||
|
||
if user is not None: | ||
login_django (request, user) | ||
return render(request, 'templates/login.html') | ||
|
||
else: | ||
return HttpResponse("Credenciais inválidas.") | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,22 +1,8 @@ | ||
""" | ||
URL configuration for mamutes project. | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/5.1/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Import the include() function: from django.urls import include, path | ||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
""" | ||
from django.contrib import admin | ||
from django.urls import path | ||
|
||
from Users import views | ||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path ('login/', views.login, name = 'login'), | ||
|
||
] |
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