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

Add models #6

Merged
merged 36 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ff12500
Add layer model
meomancer May 16, 2024
dac0305
Add import function
meomancer May 16, 2024
b6baee2
Add vector tile url
meomancer May 16, 2024
b5c57f4
Add tests
meomancer May 16, 2024
2c748f0
Add fields on Layer
meomancer May 17, 2024
99b873d
Add API
meomancer May 17, 2024
b065fdb
Add api tests
meomancer May 17, 2024
11fda95
Add permission
meomancer May 20, 2024
f47e71e
Add multi tenants
meomancer May 20, 2024
656e359
Add installer
meomancer May 20, 2024
c5ec6bc
Remove tenants
meomancer May 22, 2024
2cfb28a
Add layer type field
meomancer May 22, 2024
836ae3e
Update models
meomancer May 23, 2024
73ba283
Fix tests
meomancer May 23, 2024
7f23297
Add style model
meomancer May 23, 2024
0dfb737
Update layer fields
meomancer May 23, 2024
82ed05a
Add upload layer
meomancer May 30, 2024
2f75eec
Add style defaults
meomancer May 30, 2024
6c7ccef
Refactor code
meomancer May 31, 2024
6bafda1
Add editor url
meomancer May 31, 2024
caea79e
Integrate maputnik
meomancer Jun 4, 2024
b583aa7
Fix maputnik static url
meomancer Jun 4, 2024
a3f07a3
Add is default
meomancer Jun 4, 2024
bb1d79e
Update tests
meomancer Jun 4, 2024
c371c25
Test
meomancer Jun 4, 2024
8dae2fe
Change app name
meomancer Jun 4, 2024
01aac50
Update maputnik
meomancer Jun 5, 2024
e068940
Update models
meomancer Jun 5, 2024
f4c0854
Change term Field to Attribute
meomancer Jun 5, 2024
243b1e6
Add extra metadata
meomancer Jun 5, 2024
5e3545e
Fix flake error
meomancer Jun 6, 2024
00ea7a3
Fix flake error
meomancer Jun 6, 2024
22049cf
Clean code
meomancer Jun 6, 2024
79b5b39
Fix init
meomancer Jun 6, 2024
8352898
Fix flake
meomancer Jun 6, 2024
b0fc8c3
Fix all tests not being called
meomancer Jun 6, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Context Layer Management.
# Cloud Native GIS.
name: Tests

on:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
name: 'Django App'
runs-on: ubuntu-latest
env:
APP_IMAGE: kartoza/context_layer_management
APP_IMAGE: kartoza/cloud_native_gis
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "maputnik"]
path = maputnik
url = git@github.com:kartoza/maputnik.git
branch = cloud-native-gis
27 changes: 0 additions & 27 deletions .run/Run Server.run.xml

This file was deleted.

22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ serve:
@echo "------------------------------------------------------------------"
@cd django_project/frontend; npm install --verbose; npm run serve;

serve-maputnik:
@echo
@echo "------------------------------------------------------------------"
@echo "Execute webpack serve command"
@echo "------------------------------------------------------------------"
@cd maputnik; npm install --verbose; npm run start;

run-build-maputnik:
@echo
@echo "------------------------------------------------------------------"
@echo "Build maptunik"
@echo "------------------------------------------------------------------"
@cd maputnik; npm install --verbose; npm run build-django;

build-maputnik: run-build-maputnik
@echo
@echo "------------------------------------------------------------------"
@echo "Change html to django"
@echo "------------------------------------------------------------------"
@cd ../../;
@python3 maputnik_html_to_django.py

down:
@echo
@echo "------------------------------------------------------------------"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Kartoza Context Layer Management
# Kartoza Cloud Native GIS
4 changes: 2 additions & 2 deletions deployment/.template.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
COMPOSE_PROJECT_NAME=context_layer_management
DJANGO_SETTINGS_MODULE=core.settings.dev
COMPOSE_PROJECT_NAME=cloud_native_gis
DJANGO_SETTINGS_MODULE=core.settings.prod
DJANGO_TAG=0.0.1
HTTP_PORT=80

Expand Down
5 changes: 0 additions & 5 deletions deployment/docker-compose.override.devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ services:
db:
volumes:
- ./volumes/database:/opt/postgres/data
- ./volumes/backups:/backups

dbbackups:
volumes:
- ./volumes/backups:/backups

worker:
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}_dev
Expand Down
2 changes: 0 additions & 2 deletions deployment/docker-compose.override.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ services:
db:
volumes:
- ./volumes/database:/opt/postgres/data
- ./volumes/backups:/backups
ports:
- "${DATABASE_PORT:-6432}:5432"

Expand Down Expand Up @@ -52,7 +51,6 @@ services:
target: dev
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}_dev
volumes:
- ../django_project:/tmp/pycharm_project_258/django_project/
- ../django_project:/home/web/django_project
- ./volumes/static:/home/web/static
- ./volumes/media:/home/web/media
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
- DATABASE_PASSWORD=docker
- DATABASE_HOST=db
- RABBITMQ_HOST=rabbitmq
- DJANGO_SETTINGS_MODULE=core.settings.dev
- DJANGO_SETTINGS_MODULE=core.settings.test
- SECRET_KEY=SECRET_KEY

# Redis config
Expand Down
1 change: 0 additions & 1 deletion deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ volumes:
conf-data:
database:
nginx-cache:
backups-data:
data-volume:

x-common-django:
Expand Down
8 changes: 6 additions & 2 deletions deployment/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Django==4.2.7

# Web APIs for Django
djangorestframework==3.14.0
drf-nested-routers==0.93.5
django-cors-headers==4.3.1

# Geographic add-ons for Django Rest Framework
djangorestframework-gis==1.0
Expand All @@ -28,12 +30,14 @@ django-cleanup==7.0.0
django-celery-results==2.5.0

# psycopg2 - Python-PostgreSQL Database Adapter
# psycopg2-binary==2.9.3
psycopg2-binary==2.9.9

# This extension enables you to store the periodic task schedule in the database.
django-celery-beat==2.5.0

# Python client for Redis database and key-value store
redis==4.3.4

psycopg2-binary==2.9.9
# Library to handle geospatial functions
GeoAlchemy2==0.15.1
geopandas==0.13.2
2 changes: 1 addition & 1 deletion django_project/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Context Layer Management."""
"""Cloud Native GIS."""
1 change: 1 addition & 0 deletions django_project/cloud_native_gis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Cloud Native GIS."""
5 changes: 5 additions & 0 deletions django_project/cloud_native_gis/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Cloud Native GIS."""

from .general import *
from .layer import *
from .style import *
17 changes: 17 additions & 0 deletions django_project/cloud_native_gis/admin/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding=utf-8
"""Cloud Native GIS."""

from django.contrib import admin

from cloud_native_gis.models.general import License


class LicenseAdmin(admin.ModelAdmin):
"""License admin."""

list_display = (
'name', 'description'
)


admin.site.register(License, LicenseAdmin)
90 changes: 90 additions & 0 deletions django_project/cloud_native_gis/admin/layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# coding=utf-8
"""Cloud Native GIS."""

from django.contrib import admin
from django.utils.safestring import mark_safe

from cloud_native_gis.forms.layer import LayerForm, LayerUploadForm
from cloud_native_gis.models.layer import Layer, LayerAttributes
from cloud_native_gis.models.layer_upload import LayerUpload
from cloud_native_gis.tasks import import_data
from cloud_native_gis.utils.layer import layer_api_url, MAPUTNIK_URL


class LayerAttributeInline(admin.TabularInline):
"""LayerAttribute inline."""

model = LayerAttributes
extra = 0

def has_add_permission(self, request, obj):
"""Disable add permission."""
return False


@admin.action(description='Import data')
def start_upload_data(modeladmin, request, queryset):
"""Import data of layer."""
for layer in queryset:
import_data.delay(layer.pk)


class LayerAdmin(admin.ModelAdmin):
"""Layer admin."""

list_display = (
'unique_id', 'name', 'created_by', 'created_at', 'tile_url', 'editor'
)
form = LayerForm
inlines = [LayerAttributeInline]
filter_horizontal = ['styles']

def get_form(self, request, *args, **kwargs):
"""Return form."""
form = super(LayerAdmin, self).get_form(request, *args, **kwargs)
form.user = request.user
return form

def get_queryset(self, request):
"""Return queryset for current request."""
self.request = request
return super().get_queryset(request)

def tile_url(self, obj: Layer):
"""Return tile_url."""
return obj.absolute_tile_url(self.request)

def field_names(self, obj: Layer):
"""Return fields."""
return obj.field_names

def editor(self, obj: Layer):
"""Return fields."""
return mark_safe(
f"<a target='__blank__' href='{MAPUTNIK_URL}?"
f"api-url={layer_api_url(obj, self.request)}"
f"'>Editor</a>"
)

editor.allow_tags = True


class LayerUploadAdmin(admin.ModelAdmin):
"""Layer admin."""

list_display = (
'created_at', 'created_by', 'layer', 'status', 'progress', 'note'
)
list_filter = ['layer', 'status']
actions = [start_upload_data]
form = LayerUploadForm

def get_form(self, request, *args, **kwargs):
"""Return form."""
form = super(LayerUploadAdmin, self).get_form(request, *args, **kwargs)
form.user = request.user
return form


admin.site.register(Layer, LayerAdmin)
admin.site.register(LayerUpload, LayerUploadAdmin)
25 changes: 25 additions & 0 deletions django_project/cloud_native_gis/admin/style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding=utf-8
"""Cloud Native GIS."""

from django.contrib import admin

from cloud_native_gis.forms.style import StyleForm
from cloud_native_gis.models.style import Style


class StyleAdmin(admin.ModelAdmin):
"""Layer Style admin."""

form = StyleForm
list_display = (
'name', 'created_by', 'created_at'
)

def get_form(self, request, *args, **kwargs):
"""Return form."""
form = super(StyleAdmin, self).get_form(request, *args, **kwargs)
form.user = request.user
return form


admin.site.register(Style, StyleAdmin)
Empty file.
Loading
Loading