Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API and Django JET #26

Merged
merged 2 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The application expects a Postgres database being set up. It is easy to do so us
```
docker pull postgres

docker run --name postgres-risc -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=risc_db -p 5432:5432 postgres
docker run --name postgres-risc -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=risc_db -p 5432:5432 postgres
```

Run the initial Django migrations
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pytz==2019.2
sqlparse==0.3.0
django-import-export==1.2.0
tablib==0.13.0
django-jet==1.0.8
Binary file not shown.
Empty file added seismic_site/api/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions seismic_site/api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions seismic_site/api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
name = 'api'
Empty file.
3 changes: 3 additions & 0 deletions seismic_site/api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions seismic_site/api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions seismic_site/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from . import views

urlpatterns = [
# post views
path('building/<int:id>/', views.building, name='building'),
path('buildings', views.buildings, name='buildings'),
]
16 changes: 16 additions & 0 deletions seismic_site/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.http import HttpResponse
from django.core import serializers

from map_app import models


def buildings(request):
buildings = serializers.serialize('json', models.Building.objects.all(),
fields=('lat', 'long', 'clasa_categorie'))
return HttpResponse(buildings, content_type="application/json")


def building(request, id):
buildings = serializers.serialize(
'json', models.Building.objects.filter(pk=id))
return HttpResponse(buildings, content_type="application/json")
83 changes: 83 additions & 0 deletions seismic_site/map_app/migrations/0003_auto_20190928_1115.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Generated by Django 2.2.4 on 2019-09-28 11:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('map_app', '0002_auto_20190727_1402'),
]

operations = [
migrations.AddField(
model_name='csvfile',
name='status',
field=models.SmallIntegerField(choices=[(-1, 'Unsuccess'), (0, 'Not tried'), (1, 'Success')], default=0, editable=False),
),
migrations.AlterField(
model_name='building',
name='actualizare_pmb',
field=models.DateField(null=True),
),
migrations.AlterField(
model_name='building',
name='adresa',
field=models.CharField(max_length=250, null=True),
),
migrations.AlterField(
model_name='building',
name='an_expertiza',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='building',
name='arie_desfasurata',
field=models.FloatField(null=True),
),
migrations.AlterField(
model_name='building',
name='clasa_categorie',
field=models.CharField(max_length=250),
),
migrations.AlterField(
model_name='building',
name='editare_admin',
field=models.DateField(null=True),
),
migrations.AlterField(
model_name='building',
name='lat',
field=models.FloatField(null=True),
),
migrations.AlterField(
model_name='building',
name='long',
field=models.FloatField(null=True),
),
migrations.AlterField(
model_name='building',
name='nr_apart',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='building',
name='nr_pmb',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='building',
name='nr_postal',
field=models.CharField(max_length=250),
),
migrations.AlterField(
model_name='building',
name='nr_sector',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='building',
name='numar_cadastral',
field=models.IntegerField(null=True),
),
]
6 changes: 5 additions & 1 deletion seismic_site/seismic_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@

INSTALLED_APPS = [
'account.apps.AccountConfig',
'jet',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'map_app.apps.MapAppConfig'
'api.apps.ApiConfig',
'map_app.apps.MapAppConfig',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -67,6 +69,8 @@
},
]



WSGI_APPLICATION = 'seismic_site.wsgi.application'

# Database
Expand Down
2 changes: 2 additions & 0 deletions seismic_site/seismic_site/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from .views import index

urlpatterns = [
path('api/', include('api.urls')),
path('jet/', include('jet.urls', 'jet')),
path('admin/', admin.site.urls),
path('account/', include('account.urls')),
path('', index, name="index"),
Expand Down