From d9f7bcdafa4bc3a5fa3e0c7294a19327862e6233 Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 2 Mar 2020 01:49:44 +0100 Subject: [PATCH] move to django --- app.py | 163 ------------------ requirements.txt | 15 +- rxmap/.gitignore | 1 + rxmap/manage.py | 21 +++ rxmap/rxmap/__init__.py | 0 rxmap/rxmap/settings.py | 123 +++++++++++++ rxmap/rxmap/urls.py | 22 +++ rxmap/rxmap/wsgi.py | 16 ++ rxmap/rxmapp/__init__.py | 0 rxmap/rxmapp/admin.py | 3 + rxmap/rxmapp/apps.py | 5 + rxmap/rxmapp/migrations/0001_initial.py | 71 ++++++++ rxmap/rxmapp/migrations/__init__.py | 0 rxmap/rxmapp/models.py | 68 ++++++++ .../rxmapp/static}/jquery-ui/LICENSE.txt | 0 .../ui-bg_diagonals-thick_18_b81900_40x40.png | Bin .../ui-bg_diagonals-thick_20_666666_40x40.png | Bin .../images/ui-bg_glass_100_f6f6f6_1x400.png | Bin .../images/ui-bg_glass_100_fdf5ce_1x400.png | Bin .../images/ui-bg_glass_65_ffffff_1x400.png | Bin .../ui-bg_gloss-wave_35_f6a828_500x100.png | Bin .../ui-bg_highlight-soft_100_eeeeee_1x100.png | Bin .../ui-bg_highlight-soft_75_ffe45c_1x100.png | Bin .../images/ui-icons_222222_256x240.png | Bin .../images/ui-icons_228ef1_256x240.png | Bin .../images/ui-icons_ef8c08_256x240.png | Bin .../images/ui-icons_ffd27a_256x240.png | Bin .../images/ui-icons_ffffff_256x240.png | Bin .../static}/jquery-ui/jquery-ui.min.css | 0 .../rxmapp/static}/jquery-ui/jquery-ui.min.js | 0 {static => rxmap/rxmapp/static}/js/addmap.js | 0 {static => rxmap/rxmapp/static}/js/viewmap.js | 0 .../rxmapp/templates}/add.html | 10 ++ .../rxmapp/templates}/base.html | 4 +- rxmap/rxmapp/templates/index.html | 33 ++++ rxmap/rxmapp/tests.py | 3 + rxmap/rxmapp/urls.py | 29 ++++ rxmap/rxmapp/views.py | 12 ++ rxmap/static/.gitignore | 1 + templates/index.html | 12 -- 40 files changed, 424 insertions(+), 188 deletions(-) delete mode 100644 app.py create mode 100644 rxmap/.gitignore create mode 100755 rxmap/manage.py create mode 100644 rxmap/rxmap/__init__.py create mode 100644 rxmap/rxmap/settings.py create mode 100644 rxmap/rxmap/urls.py create mode 100644 rxmap/rxmap/wsgi.py create mode 100644 rxmap/rxmapp/__init__.py create mode 100644 rxmap/rxmapp/admin.py create mode 100644 rxmap/rxmapp/apps.py create mode 100644 rxmap/rxmapp/migrations/0001_initial.py create mode 100644 rxmap/rxmapp/migrations/__init__.py create mode 100644 rxmap/rxmapp/models.py rename {static => rxmap/rxmapp/static}/jquery-ui/LICENSE.txt (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-icons_222222_256x240.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-icons_228ef1_256x240.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-icons_ef8c08_256x240.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-icons_ffd27a_256x240.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/images/ui-icons_ffffff_256x240.png (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/jquery-ui.min.css (100%) rename {static => rxmap/rxmapp/static}/jquery-ui/jquery-ui.min.js (100%) rename {static => rxmap/rxmapp/static}/js/addmap.js (100%) rename {static => rxmap/rxmapp/static}/js/viewmap.js (100%) rename {templates => rxmap/rxmapp/templates}/add.html (82%) rename {templates => rxmap/rxmapp/templates}/base.html (92%) create mode 100644 rxmap/rxmapp/templates/index.html create mode 100644 rxmap/rxmapp/tests.py create mode 100644 rxmap/rxmapp/urls.py create mode 100644 rxmap/rxmapp/views.py create mode 100644 rxmap/static/.gitignore delete mode 100644 templates/index.html diff --git a/app.py b/app.py deleted file mode 100644 index f72bb3e..0000000 --- a/app.py +++ /dev/null @@ -1,163 +0,0 @@ -import flask -import sqlite3 -from datetime import datetime - -from flask import Flask, render_template, redirect, url_for, request, jsonify -from flask_sqlalchemy import SQLAlchemy - -import sqlalchemy.exc -from sqlalchemy_utils import PasswordType - -# from sqlalchemy import Column, Integer, String -# from sqlalchemy.ext.declarative import declarative_base - -# TODO: sqlalchemy? - -# schema: -# Utente: uid, username, password -# TipoRadio: trid, tipo -# Avvistamento: aid, uid, tipo_radio, data, commento - -app = Flask(__name__) -app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///map.db" -db = SQLAlchemy(app) - - -class User(db.Model): - __tablename__ = "user" - - uid = db.Column(db.Integer, primary_key=True, nullable=False) - username = db.Column(db.String, unique=True) - password = db.Column(PasswordType(schemes=["pbkdf2_sha512"])) - - rapporti = db.relationship("RapportoRicezione") - - -class TipoRadio(db.Model): - __tablename__ = "tiporadio" - tid = db.Column(db.Integer, primary_key=True, nullable=False) - nome = db.Column(db.Unicode) - descrizione = db.Column(db.Unicode) - - rapporti = db.relationship("RapportoRicezione") - - -class RapportoRicezione(db.Model): - __tablename__ = "rapporto" - - rid = db.Column(db.Integer, primary_key=True) - uid = db.Column(db.Integer, db.ForeignKey("user.uid")) - tid = db.Column(db.Integer, db.ForeignKey("tiporadio.tid")) - - date = db.Column(db.Date, default=lambda: datetime.now()) - - lat = db.Column(db.Float) - lng = db.Column(db.Float) - - comprensibile = db.Column(db.Integer) # TODO: >= 0 <= 5 - stabilita = db.Column(db.Integer) # TODO: >= 0 <= 5 - - author = db.relationship(User, back_populates="rapporti") - tipo_radio = db.relationship(TipoRadio, back_populates="rapporti") - - def serialize(self): - d = {k:v for k,v in self.__dict__.items() if not k.startswith('_')} - d['colore'] = self.colore - d['radius'] = self.radius - d['explaination'] = self.explaination - return d - - @property - def colore(self): - c = self.comprensibile - if c > 3: - return 'green' - if c > 1: - return 'yellow' - return 'red' - - @property - def radius(self): - return self.stabilita * 70 - - @property - def explaination(self): - return 'Aggiunto il %s da %s' % (self.date, self.author.username) - - def __repr__(self): - return "" % (self.rid, self.date) - - -@app.before_first_request -def init_db(): - db.create_all() - - try: - anon = User(username="anonymous", password="antani") - db.session.add(anon) - db.session.commit() - except sqlalchemy.exc.IntegrityError: - db.session.rollback() - - for nome in ["radiolina portatile", "autoradio", "stereo fisso dentro casa"]: - try: - t = TipoRadio(nome=nome) - db.session.add(t) - db.session.commit() - except sqlalchemy.exc.IntegrityError: - db.session.rollback() - - cnt = int(RapportoRicezione.query.count()) - if cnt == 0: - for i in range(6): - r = RapportoRicezione( - uid=User.query.filter(User.username == "anonymous")[0].uid, - tid=TipoRadio.query.all()[0].tid, - stabilita=i, - comprensibile=i, - lat=43.8199 - i * 0.01, - lng=11.22185 + i * 0.03, - ) - db.session.add(r) - db.session.commit() - - -@app.route("/") -def home(): - return render_template("index.html") - -@app.route("/add") -def add(): - return render_template("add.html") - - -@app.route("/api/rapporti/get") -def get_rapporti(): - query = RapportoRicezione.query.all() - # TODO: usa query params per filtrare in base a $cose - return jsonify(dict(rapporti=[r.serialize() for r in query])) - -@app.route("/api/rapporti/add", methods=['POST']) -def add_rapporto(): - anon = User.query.filter(User.username=='anonymous')[0].uid - r = RapportoRicezione( - uid=anon, - lat=request.form['lat'], - lng=request.form['lng'], - stabilita=request.form['stabilita'], - comprensibile=request.form['comprensibile'], - - ) - db.session.add(r) - db.session.commit() - - r = RapportoRicezione.query.get(r.rid) - return jsonify(r.serialize()) - -@app.route("/api/rapporti/delete", methods=['POST']) -def delete_rapporto(): - r = RapportoRicezione.query.get(int(request.form['rid'])) - db.session.delete(r) - db.session.commit() - - return jsonify(True) diff --git a/requirements.txt b/requirements.txt index a4cfbbe..b86b6f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,4 @@ -Click==7.0 -Flask-SQLAlchemy==2.4.1 -Flask==1.1.1 -Jinja2==2.11.1 -MarkupSafe==1.1.1 -SQLAlchemy-Utils==0.36.1 -SQLAlchemy==1.3.13 -Werkzeug==1.0.0 -itsdangerous==1.1.0 -passlib==1.7.2 -six==1.14.0 +Django==2.2 +gunicorn==20.0.4 +pytz==2019.3 +sqlparse==0.3.1 diff --git a/rxmap/.gitignore b/rxmap/.gitignore new file mode 100644 index 0000000..6061583 --- /dev/null +++ b/rxmap/.gitignore @@ -0,0 +1 @@ +*.sqlite3 diff --git a/rxmap/manage.py b/rxmap/manage.py new file mode 100755 index 0000000..31e1206 --- /dev/null +++ b/rxmap/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rxmap.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/rxmap/rxmap/__init__.py b/rxmap/rxmap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rxmap/rxmap/settings.py b/rxmap/rxmap/settings.py new file mode 100644 index 0000000..a2657ca --- /dev/null +++ b/rxmap/rxmap/settings.py @@ -0,0 +1,123 @@ +""" +Django settings for rxmap project. + +Generated by 'django-admin startproject' using Django 2.2. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.2/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'o4-qdex8sx_b3i!hu81qtri*-&pztgkolc^p()r0g3vauzk+^b' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'rxmapp', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'rxmap.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'rxmap.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators + +AUTH_USER_MODEL = 'rxmapp.User' +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.2/topics/i18n/ + +LANGUAGE_CODE = 'it-it' + +TIME_ZONE = 'Europe/Rome' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + +STATIC_URL = '/static/' +STATIC_ROOT = 'static' diff --git a/rxmap/rxmap/urls.py b/rxmap/rxmap/urls.py new file mode 100644 index 0000000..11266cb --- /dev/null +++ b/rxmap/rxmap/urls.py @@ -0,0 +1,22 @@ +"""rxmap URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('rxmapp.urls')), +] diff --git a/rxmap/rxmap/wsgi.py b/rxmap/rxmap/wsgi.py new file mode 100644 index 0000000..a5f7c84 --- /dev/null +++ b/rxmap/rxmap/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for rxmap project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rxmap.settings') + +application = get_wsgi_application() diff --git a/rxmap/rxmapp/__init__.py b/rxmap/rxmapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rxmap/rxmapp/admin.py b/rxmap/rxmapp/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rxmap/rxmapp/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rxmap/rxmapp/apps.py b/rxmap/rxmapp/apps.py new file mode 100644 index 0000000..a56e999 --- /dev/null +++ b/rxmap/rxmapp/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class RxmappConfig(AppConfig): + name = 'rxmapp' diff --git a/rxmap/rxmapp/migrations/0001_initial.py b/rxmap/rxmapp/migrations/0001_initial.py new file mode 100644 index 0000000..c9fd8f7 --- /dev/null +++ b/rxmap/rxmapp/migrations/0001_initial.py @@ -0,0 +1,71 @@ +# Generated by Django 2.2 on 2020-03-01 15:46 + +import datetime +from django.conf import settings +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0011_update_proxy_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + migrations.CreateModel( + name='TipoRadio', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome', models.CharField(max_length=64, unique=True)), + ('descrizione', models.CharField(max_length=1000)), + ], + ), + migrations.CreateModel( + name='RapportoRicezione', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField(default=datetime.datetime.now)), + ('lat', models.FloatField()), + ('lng', models.FloatField()), + ('comprensibile', models.IntegerField()), + ('stabilita', models.IntegerField()), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='rapporti', to=settings.AUTH_USER_MODEL)), + ('tipo_radio', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='rapporti', to='rxmapp.TipoRadio')), + ], + options={ + 'verbose_name': 'rapporto ricezione', + }, + ), + ] diff --git a/rxmap/rxmapp/migrations/__init__.py b/rxmap/rxmapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rxmap/rxmapp/models.py b/rxmap/rxmapp/models.py new file mode 100644 index 0000000..998b520 --- /dev/null +++ b/rxmap/rxmapp/models.py @@ -0,0 +1,68 @@ +from django.db import models +from datetime import datetime +from django.contrib.auth.models import AbstractUser + +# Create your models here. +class User(AbstractUser): + pass + + +class TipoRadio(models.Model): + #tid = db.Column(db.Integer, primary_key=True, nullable=False) + nome = models.CharField(max_length=64, unique=True) + descrizione = models.CharField(max_length=1000) + + #rapporti = db.relationship("RapportoRicezione") + + +class RapportoRicezione(models.Model): + class Meta: + verbose_name = 'rapporto ricezione' + #verbose_plural_name = 'rapporti ricezione' + + #rid = db.Column(db.Integer, primary_key=True) + author = models.ForeignKey(User, related_name='rapporti', on_delete=models.PROTECT) + tipo_radio = models.ForeignKey(TipoRadio, on_delete=models.PROTECT, related_name='rapporti') + + date = models.DateField(default=datetime.now) + + lat = models.FloatField() + lng = models.FloatField() + + comprensibile = models.IntegerField() # TODO: >= 0 <= 5 + stabilita = models.IntegerField() # TODO: >= 0 <= 5 + + def serialize(self): + d = {k: v for k, v in self.__dict__.items() if not k.startswith("_")} + d["colore"] = self.colore + d["radius"] = self.radius + d["explaination"] = self.explaination + return d + + @property + def colore(self): + c = self.comprensibile + if c > 3: + return "green" + if c > 1: + return "yellow" + return "red" + + @property + def radius(self): + return self.stabilita * 70 + + @property + def explaination(self): + return """ + Ricevuto con %s + Aggiunto il %s da %s + """ % ( + self.tipo_radio.nome, + self.date, + self.author.username, + ) + + def __str__(self): + return "" % (self.rid, self.date) + diff --git a/static/jquery-ui/LICENSE.txt b/rxmap/rxmapp/static/jquery-ui/LICENSE.txt similarity index 100% rename from static/jquery-ui/LICENSE.txt rename to rxmap/rxmapp/static/jquery-ui/LICENSE.txt diff --git a/static/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png similarity index 100% rename from static/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png diff --git a/static/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png similarity index 100% rename from static/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png diff --git a/static/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/static/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png diff --git a/static/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png diff --git a/static/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png b/rxmap/rxmapp/static/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png diff --git a/static/jquery-ui/images/ui-icons_222222_256x240.png b/rxmap/rxmapp/static/jquery-ui/images/ui-icons_222222_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_222222_256x240.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-icons_222222_256x240.png diff --git a/static/jquery-ui/images/ui-icons_228ef1_256x240.png b/rxmap/rxmapp/static/jquery-ui/images/ui-icons_228ef1_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_228ef1_256x240.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-icons_228ef1_256x240.png diff --git a/static/jquery-ui/images/ui-icons_ef8c08_256x240.png b/rxmap/rxmapp/static/jquery-ui/images/ui-icons_ef8c08_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_ef8c08_256x240.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-icons_ef8c08_256x240.png diff --git a/static/jquery-ui/images/ui-icons_ffd27a_256x240.png b/rxmap/rxmapp/static/jquery-ui/images/ui-icons_ffd27a_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_ffd27a_256x240.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-icons_ffd27a_256x240.png diff --git a/static/jquery-ui/images/ui-icons_ffffff_256x240.png b/rxmap/rxmapp/static/jquery-ui/images/ui-icons_ffffff_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_ffffff_256x240.png rename to rxmap/rxmapp/static/jquery-ui/images/ui-icons_ffffff_256x240.png diff --git a/static/jquery-ui/jquery-ui.min.css b/rxmap/rxmapp/static/jquery-ui/jquery-ui.min.css similarity index 100% rename from static/jquery-ui/jquery-ui.min.css rename to rxmap/rxmapp/static/jquery-ui/jquery-ui.min.css diff --git a/static/jquery-ui/jquery-ui.min.js b/rxmap/rxmapp/static/jquery-ui/jquery-ui.min.js similarity index 100% rename from static/jquery-ui/jquery-ui.min.js rename to rxmap/rxmapp/static/jquery-ui/jquery-ui.min.js diff --git a/static/js/addmap.js b/rxmap/rxmapp/static/js/addmap.js similarity index 100% rename from static/js/addmap.js rename to rxmap/rxmapp/static/js/addmap.js diff --git a/static/js/viewmap.js b/rxmap/rxmapp/static/js/viewmap.js similarity index 100% rename from static/js/viewmap.js rename to rxmap/rxmapp/static/js/viewmap.js diff --git a/templates/add.html b/rxmap/rxmapp/templates/add.html similarity index 82% rename from templates/add.html rename to rxmap/rxmapp/templates/add.html index d5d5b6d..34710aa 100644 --- a/templates/add.html +++ b/rxmap/rxmapp/templates/add.html @@ -29,6 +29,16 @@ + +
+ + +
+ diff --git a/templates/base.html b/rxmap/rxmapp/templates/base.html similarity index 92% rename from templates/base.html rename to rxmap/rxmapp/templates/base.html index 0bf0f3b..1f9846f 100644 --- a/templates/base.html +++ b/rxmap/rxmapp/templates/base.html @@ -40,8 +40,8 @@ footer { {% block main %} diff --git a/rxmap/rxmapp/templates/index.html b/rxmap/rxmapp/templates/index.html new file mode 100644 index 0000000..0abae0e --- /dev/null +++ b/rxmap/rxmapp/templates/index.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} +{% load static %} + +{% block extra_css %} + +{% endblock extra_css %} +{% block extra_scripts %} + + +{% endblock extra_scripts %} + +{% block content %} +
+
+

Filtra

+
+ +
+ + +
+ + + + +
+
+{% endblock content %} diff --git a/rxmap/rxmapp/tests.py b/rxmap/rxmapp/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rxmap/rxmapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rxmap/rxmapp/urls.py b/rxmap/rxmapp/urls.py new file mode 100644 index 0000000..f2be344 --- /dev/null +++ b/rxmap/rxmapp/urls.py @@ -0,0 +1,29 @@ +"""rxmap URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include +from django.views.generic import TemplateView + +from . import views + +urlpatterns = [ + path('', TemplateView.as_view(template_name='index.html'), name="home"), + path('add', TemplateView.as_view(template_name='add.html'), name="add"), + path('api/rapporti/get', views.rapporti_get), + #path('api/rapporti/add', views.rapporti_add), + #path('api/rapporti/delete', views.rapporti_delete), +] + diff --git a/rxmap/rxmapp/views.py b/rxmap/rxmapp/views.py new file mode 100644 index 0000000..cfb73a7 --- /dev/null +++ b/rxmap/rxmapp/views.py @@ -0,0 +1,12 @@ +from django.shortcuts import render +from django.http import JsonResponse + +from .models import RapportoRicezione + +# Create your views here. + +def rapporti_get(request): + return JsonResponse([ + r.serialize() + for r in RapportoRicezione.objects.all() + ], safe=False) diff --git a/rxmap/static/.gitignore b/rxmap/static/.gitignore new file mode 100644 index 0000000..355164c --- /dev/null +++ b/rxmap/static/.gitignore @@ -0,0 +1 @@ +*/ diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index bd8ec80..0000000 --- a/templates/index.html +++ /dev/null @@ -1,12 +0,0 @@ -{% extends 'base.html' %} -{% block extra_css %} - -{% endblock extra_css %} -{% block extra_scripts %} - - -{% endblock extra_scripts %} - -{% block content %} -
-{% endblock content %}