-
Notifications
You must be signed in to change notification settings - Fork 2
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 #2 from fga-gpp-mds/development
0.1 is Kraken "Release The Kraken"
- Loading branch information
Showing
20 changed files
with
139 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
#SQLite | ||
*.sqlite3 |
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
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,27 @@ | ||
# 2017.2-DepuTinder-API | ||
## 2017.2 - meRepresenta - Rest API | ||
|
||
|
||
<p align="justify">  A API do software possui um repositório destinado a ela. Este pode ser acessado no endereço a seguir: | ||
[meRepresenta](https://github.com/fga-gpp-mds/2017.2-DepuTinder)</p> | ||
|
||
### Instalação | ||
|
||
<p align="justify">  Para que seja possível a utilização da API, é preciso executar o makemigrations. Este comando é necessário para criação de novas migrações relacionadas às models:</p> | ||
|
||
``` | ||
python3 manage.py makemigrations | ||
``` | ||
|
||
<p align="justify">  Para que essas migrações possam ser manipuladas, tanto na aplicação de novas quando no exclusão das existentes, é necessário executar o comando:</p> | ||
|
||
``` | ||
python3 manage.py migrate | ||
``` | ||
|
||
<p align="justify">  Para executar a API é fundamental o seguinte comando: </p> | ||
|
||
``` | ||
python3 manage.py runserver | ||
``` | ||
|
||
<p align="justify">  Para acessar o servidor gerado no comando anterior, basta acessar [localhost:8000](http://localhost:8000/)</p> |
Binary file not shown.
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.contrib import admin | ||
|
||
# Register your models 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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class PropositionsConfig(AppConfig): | ||
name = 'propositions' |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-09-27 07:47 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Propositions', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('propositionID', models.IntegerField()), | ||
('propositionTitle', models.CharField(blank=True, max_length=100)), | ||
('propositionSubTitle', models.CharField(blank=True, max_length=150)), | ||
('propositionDescription', models.CharField(blank=True, max_length=200)), | ||
('propositionAuthor', models.CharField(blank=True, max_length=50)), | ||
], | ||
), | ||
] |
19 changes: 19 additions & 0 deletions
19
propositions/migrations/0002_remove_propositions_propositionid.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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-09-27 20:17 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('propositions', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='propositions', | ||
name='propositionID', | ||
), | ||
] |
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,7 @@ | ||
from django.db import models | ||
|
||
class Propositions(models.Model): | ||
propositionTitle = models.CharField(max_length=100, blank=True) | ||
propositionSubTitle = models.CharField(max_length=150, blank=True) | ||
propositionDescription = models.CharField(max_length=200, blank=True) | ||
propositionAuthor = models.CharField(max_length=50, blank=True) |
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,7 @@ | ||
from rest_framework import serializers | ||
from .models import Propositions | ||
|
||
class PropositionsSerializer(serializers.Serializer): | ||
class Meta: | ||
model = Propositions | ||
fields = ('propositionTitle', 'propositionSubTitle', 'propositionDescription', 'propositionAuthor') |
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,5 @@ | ||
from django.conf.urls import url | ||
from .views import propositions | ||
|
||
urlpatterns = [ | ||
] |
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,20 @@ | ||
from django.shortcuts import render | ||
from .models import Propositions | ||
from .serializers import PropositionsSerializer | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from rest_framework.decorators import api_view | ||
import requests, json | ||
|
||
@api_view(['GET']) | ||
def propositions(request): | ||
propositions = Propositions.objects.all() | ||
|
||
if propositions: | ||
return Response({}, status=status.HTTP_404_NOT_FOUND) | ||
else: | ||
serializer = PropositionsSerializer(propositions) | ||
r = requests.get('https://api.myjson.com/bins/m7f4x', serializer) | ||
data = json.loads(r.text) | ||
|
||
return Response(data, status=status.HTTP_201_CREATED) |