Commit 46721912 authored by amandazk's avatar amandazk

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

parents 265c668e 16ac1491
# 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-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import phonenumber_field.modelfields
......@@ -11,7 +9,6 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
......@@ -32,12 +29,9 @@ 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
......@@ -16,11 +15,6 @@ 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):
......
......@@ -15,7 +15,10 @@ class PessoaDestroy(generics.DestroyAPIView):
queryset = Pessoa.objects.all()
serializer_class = PessoaSerializer
permission_classes = ()
<<<<<<< HEAD
=======
>>>>>>> 16ac14913355c95f9673586f8697b081a9396cfc
class PessoaUpdate(generics.UpdateAPIView):
......@@ -23,7 +26,10 @@ class PessoaUpdate(generics.UpdateAPIView):
queryset = Pessoa.objects.all()
serializer_class = PessoaSerializer
permission_classes = ()
<<<<<<< HEAD
=======
>>>>>>> 16ac14913355c95f9673586f8697b081a9396cfc
class PessoaCreate(generics.CreateAPIView):
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
......
# Generated by Django 3.1.3 on 2021-01-14 14:18
# Generated by Django 3.1.3 on 2021-01-04 13:19
from django.db import migrations, models
import django.db.models.deletion
......
......@@ -156,19 +156,19 @@ export default {
this.log.console(response);
});
},
// addFone() {
// axios
// .post("http://localhost:8000/api/fones/add/", this.fone, {
// headers: {
// Authorization: `Token ${this.$session.get("token")}`,
// },
// })
// .then((response) => {
// this.dialog = false;
// this.$emit("updateFone");
// this.log.console(response);
// });
// },
addFone() {
axios
.post("/api/fones/add/", this.fone, {
headers: {
Authorization: `Token ${this.$session.get("token")}`,
},
})
.then((response) => {
this.dialog = false;
this.$emit("updateFone");
this.log.console(response);
});
},
},
};
</script>
......
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