Commit eb5c0811 authored by amandazk's avatar amandazk

Merge branch 'master' of https://github.com/amandazk/projeto-IFC

parents a1688d6c 53a07764
# Projeto Portal
## Backend
:point_right: Criar uma pasta para o projeto:
```
mkdir pasta_projeto
cd pasta_projeto
```
:point_right: Criar um ambiente virtual:
```
python3 -m venv {nome_do_ambiente}
source venv/bin/activate
```
:point_right: Para instalar os requirements:
```
pip install -r requirements.txt
```
:point_right: É nessário criar um banco de dados no postgreSQL e colocar as configurações no 'settings.py':
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '{nome_do_banco}',
'USER': '{nome_do_usuario}',
'PASSWORD': '{senha_do_banco}',
'HOST': 'localhost',
'PORT': '5432'
}
}
```
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import phonenumber_field.modelfields
......@@ -9,6 +11,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
......@@ -29,9 +32,12 @@ class Migration(migrations.Migration):
('pessoa_id', models.AutoField(primary_key=True, serialize=False)),
('cpf_pessoa', models.CharField(max_length=11, unique=True)),
('nome_pessoa', models.CharField(max_length=200)),
('username', models.CharField(max_length=100, unique=True)),
('password', models.CharField(max_length=30)),
('nasc_pessoa', models.DateField()),
('email_pessoa', models.EmailField(max_length=254)),
('fone', models.ManyToManyField(related_name='pessoas', to='pessoas.Fone')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Pessoa',
......
# Generated by Django 3.1.3 on 2021-01-04 13:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pessoas', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='pessoa',
name='password',
field=models.CharField(default='', max_length=30),
preserve_default=False,
),
migrations.AddField(
model_name='pessoa',
name='username',
field=models.CharField(default=' ', max_length=100, unique=True),
preserve_default=False,
),
]
from django.db import models
from django.contrib.auth.models import User
class Pessoa(models.Model):
objects = models.Manager() #evitar erro no vscode
......@@ -15,6 +16,12 @@ class Pessoa(models.Model):
related_name='pessoas'
)
user = models.OneToOneField(
User,
on_delete = models.CASCADE
)
def __str__(self):
return self.nome_pessoa
......
......@@ -14,27 +14,23 @@ class FoneDestroy(generics.DestroyAPIView):
"""Excluindo fone"""
queryset = Fone.objects.all()
serializer_class = FoneSerializer
permission_classes = (
permissions.IsAdminUser,
)
permission_classes = ()
class FoneUpdate(generics.UpdateAPIView):
"""Update de fone"""
queryset = Fone.objects.all()
serializer_class = FoneSerializer
permission_classes = (
permissions.IsAuthenticated,
)
permission_classes = ()
class FoneCreate(generics.CreateAPIView):
"""Criando fone"""
queryset = Fone.objects.all()
serializer_class = FoneSerializer
permission_classes = (
permissions.DjangoModelPermissions,
)
permission_classes = ()
class FoneGet(generics.RetrieveAPIView):
......
......@@ -14,28 +14,20 @@ class PessoaDestroy(generics.DestroyAPIView):
"""Excluindo pessoa"""
queryset = Pessoa.objects.all()
serializer_class = PessoaSerializer
permission_classes = (
permissions.IsAdminUser,
)
permission_classes = ()
class PessoaUpdate(generics.UpdateAPIView):
"""Update de pessoa"""
queryset = Pessoa.objects.all()
serializer_class = PessoaSerializer
permission_classes = (
permissions.IsAuthenticated,
)
permission_classes = ()
class PessoaCreate(generics.CreateAPIView):
"""Criando pessoa"""
queryset = Pessoa.objects.all()
serializer_class = PessoaSerializer
permission_classes = (
permissions.DjangoModelPermissions,
)
permission_classes = ()
class PessoaGet(generics.RetrieveAPIView):
"""Listando uma pessoa"""
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
......@@ -8,8 +8,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('oferta', '0001_initial'),
('voluntariado', '0001_initial'),
('oferta', '0001_initial'),
]
operations = [
......
# Generated by Django 3.1.3 on 2021-01-04 13:19
# Generated by Django 3.1.3 on 2021-01-15 16:23
from django.db import migrations, models
import django.db.models.deletion
......
......@@ -158,7 +158,7 @@ export default {
},
// addFone() {
// axios
// .post("http://localhost:8000/api/fones/add/", this.fone, {
// .post("/api/fones/add/", this.fone, {
// headers: {
// Authorization: `Token ${this.$session.get("token")}`,
// },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment