Commit 760acb74 authored by fred.perso's avatar fred.perso

First push

parents
"""
Django settings for dbchiro project.
Generated by 'django-admin startproject' using Django 1.11.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/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/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'f0q1uri4bg8a4h!!@rcw6cktb-x%fh!q23x&-upn95#v547z(f'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '[::1]', '.dbchiro.org']
# Application definition
INSTALLED_APPS = [
'admin_view_permission',
'grappelli',
'nested_admin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'debug_toolbar',
# 'sortedm2m',
'sights',
'ckeditor',
'leaflet',
'crispy_forms',
]
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',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'dbchiro.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'sights/template')
],
'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 = 'dbchiro.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'dbchiroweb',
'USER': 'dbadmin',
'PASSWORD': 'dbadminpasswd',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
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/1.11/topics/i18n/
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
GRAPPELLI_SWITCH_USER = True
CRISPY_TEMPLATE_PACK = 'uni_form'
LEAFLET_CONFIG = {
'DEFAULT_CENTER': (5, 45.0),
'DEFAULT_ZOOM': 8,
'MIN_ZOOM': 3,
'MAX_ZOOM': 18,
'TILES': [
('OpenStreetMap Mapnik', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'),
('OpenTopoMap', 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
'&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>'),
],
'SCALE': 'both',
}
"""dbchiro URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib.gis import admin
from django.contrib.auth import views
from django.conf import settings
admin.autodiscover()
urlpatterns = [
url(r'^grappelli/', include('grappelli.urls')),
url(r'^nested_admin/', include('nested_admin.urls')),
url(r'^admin/', admin.site.urls),
# url(r'^accounts/login/', views.login),
url(r'', include('sights.urls')),
]
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
"""
WSGI config for dbchiro 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/1.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dbchiro.settings")
application = get_wsgi_application()
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dbchiro.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
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?"
)
raise
execute_from_command_line(sys.argv)
from django.contrib import admin
from django.contrib.gis import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from .models import Place, Observer, Sighting, Session, Capture, PlaceDetail, UserDetail, CatchAuth, CountDetail
from leaflet.admin import LeafletGeoAdmin
# from nested_inline.admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline
# from olwidget.admin import GeoModelAdmin
import nested_admin
class UserDetailInline(nested_admin.NestedStackedInline):
model = UserDetail
can_delete = False
verbose_name_plural = 'Details de utilisateur'
class UserAdmin(LeafletGeoAdmin):
inlines = (UserDetailInline, )
class CountDetailInLine(nested_admin.NestedTabularInline):
model = CountDetail
extra = 0
fk_name = 'sighting'
# class CaptureInLine(admin.StackedInline):
class CaptureInLine(nested_admin.NestedTabularInline):
model = Capture
extra = 0
# fk_name = 'sighting'
class SightingInLine(nested_admin.NestedTabularInline):
model = Sighting
extra = 0
# fk_name = 'session'
inlines = [CaptureInLine, CountDetailInLine, ]
class SessionInLine(nested_admin.NestedTabularInline):
model = Session
extra = 0
# fk_name = 'place'
inlines = [SightingInLine, ]
class SightingAdmin(admin.ModelAdmin):
inlines = [
CountDetailInLine, CaptureInLine
]
# class PlaceAdmin(nested_admin.NestedModelAdmin):
# class PlaceAdmin(nested_admin.NestedModelAdmin):
class PlaceAdmin(LeafletGeoAdmin):
model = Place
inlines = [SessionInLine, ]
list_display = ['name', 'municipality', ]
search_fields = ['name', 'municipality']
sortable_field_name = "municipality"
autocomplete_lookup_fields = {
'name': ['name', 'municipality'],
}
# class CaptureAdmin(admin.ModelAdmin):
# list_display = ['sighting', 'age', 'sex', 'ab']
# list_filter = ['sex', 'age', 'sighting']
# search_fields = ['sighting']
# sortable_field_name = "sighting"
# autocomplete_lookup_fields = {
# 'sighting': ['sighting'],
# }
#
# def related_sighting(self, obj):
# return obj.id_sighting.codesp
# related_sighting.short_description = 'Sighting'
admin.site.register(Place, PlaceAdmin)
# admin.site.register(PlaceDetail)
# admin.site.register(Session)
admin.site.register(Sighting, SightingAdmin)
admin.site.register(Observer)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(CatchAuth)
# Register your models here.
from django.apps import AppConfig
class SightsConfig(AppConfig):
name = 'sights'
from django import forms
from .models import Place
class PlaceForm(forms.ModelForm):
class Meta:
model = Place
This diff is collapsed.
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-05-09 22:45
from __future__ import unicode_literals
import django.contrib.gis.db.models.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sights', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='sighting',
name='bdsource',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='bdd source'),
),
migrations.AlterField(
model_name='sighting',
name='codesp',
field=models.CharField(choices=[('rhifer', 'Grand rhinolophe'), ('rhihip', 'Petit rhinolophe'), ('rhieur', 'Rhinolophe euryale'), ('rhimeh', 'Rhinolophe de Mehely'), ('myomys', 'Murin à moustaches'), ('myobra', 'Murin de Brandt'), ('myoalc', 'Murin dAlcathoé'), ('myoema', 'Murin à oreilles échancrées'), ('myonat', 'Murin de Natterer'), ('myobec', 'Murin de Bechstein'), ('myomyo', 'Grand Murin'), ('myobly', 'Petit Murin'), ('myopun', 'Murin du Magrheb'), ('myodau', 'Murin de Daubenton'), ('myocap', 'Murin de Capaccini'), ('myodas', 'Murin des marais'), ('nyclas', 'Grande Noctule'), ('nyclei', 'Noctule de Leisler'), ('nycnoc', 'Noctule commune'), ('eptser', 'Sérotine commune'), ('eptnil', 'Sérotine de Nilsson'), ('vesmur', 'Sérotine bicolore'), ('pippip', 'Pipistrelle commune'), ('pippyg', 'Pipistrelle pygmée'), ('pipnat', 'Pipistrelle de Nathusius'), ('pipkuh', 'Pipistrelle de Kuhl'), ('hypsav', 'Vespère de Savi'), ('pleaur', 'Oreillard roux'), ('pleaus', 'Oreillard gris'), ('plemac', 'Oreillard montagnard'), ('barbar', 'Barbastelle dEurope'), ('minsch', 'Minioptère de Schreibers'), ('tadten', 'Molosse de Cestoni'), ('rhieurfer', 'Grand rhinolophe / Rhinolophe euryale'), ('rhiind', 'Rhinolophe indéterminé'), ('petmur', 'Murin de "petite taille"'), ('murmur', 'Murin de "grande taille"'), ('nycind', 'Noctule indéterminée'), ('nyctad', 'Noctule / Molosse'), ('eptind', 'Sérotine indéterminée'), ('eptnyc', 'Sérotine / Noctule'), ('eptvesnyc', 'Sérotine / Noctule'), ('eptmur', 'Sérotine / Murin de "grande taille"'), ('pipind', 'Pipistrelle indéterminée'), ('pleind', 'Oreillard indéterminé'), ('myobecdaumys', 'Murin de Bechstein / Daubenton / moustaches'), ('myodauemamys', 'Murin de Daubenton / moustaches / emarginé'), ('myobecdau', 'Murin de Bechstein / Daubenton'), ('myobecbradau', 'Murin de Bechstein / Brandt / Daubenton'), ('myobecbra', 'Murin de Bechstein / Brandt'), ('myobecema', 'Murin de Bechstein / émarginé'), ('myoalcmys', 'Murin dAlcathoé / moustaches'), ('myoalcbramys', 'Murin dAlcathoé / Brandt / moustaches'), ('myodaumys', 'Murin de Daubenton / moustaches'), ('myoemamys', 'Murin émarginé / moustaches'), ('myoalcemamys', 'Murin dAlcathoé / émarginé / moustaches'), ('myoalcema', 'Murin dAlcathoé / émarginé'), ('nycnoclas', 'Noctule commune / Grande noctule'), ('pipkuhnat', 'Pipistrelle de Kuhl / Nathusius'), ('pippipnat', 'Pipistrelle commune / Nathusius'), ('pippipminsch', 'Pipistrelle commune / Minioptère'), ('pippygminsch', 'Pipistrelle pygmée / Minioptère'), ('chiind', 'Chiroptère indéterminé'), ('0cfil', 'Aucune capture filet'), ('0obs', 'Aucune chauve-souris ou trace'), ('0du', 'Aucun contact acoustique'), ('minfos', 'Miniopterus fossilis'), ('myoalccapmys', 'Murin dAlcathoé / Capaccini / moustaches'), ('myoalcdau', 'Murin dAlcathoe / de Daubenton'), ('myobecbraema', 'Murin de Bechstein / Brandt / émarginé'), ('myobecbramur', 'Murin de Bechstein / Brandt / "grande taille"'), ('myobecbramys', 'Murin de Bechstein / Brandt / moustaches'), ('myobecdaumur', 'Murin de Bechstein /Daubenton/"grande taille"'), ('myobecmur', 'Murin de Bechstein / murin de "grande taille"'), ('myoboy', 'Myotis boyeri'), ('myobradau', 'Murin de Brandt / Daubenton'), ('myobradaumys', 'Murin de Brandt / Daubenton / moustaches'), ('myobraema', 'Murin de Brandt / échancré'), ('myobraemamys', 'Murin de Brandt / émarginé / moustaches'), ('myobramys', 'Murin de Brandt / moustaches'), ('myocapdau', 'Murin de Capaccini / de Daubenton'), ('myocapdauema', 'Murin de Capaccini / Daubenton / émarginé'), ('myodauema', 'Murin de Daubenton / émarginé'), ('myoesc', 'Murin dEscalera'), ('myonatbly', 'Murin de Natterer / Petit murin'), ('myosan', 'Myotis sanctialbani'), ('myotis', 'Murin indét. (PETMUR/MURMUR)'), ('nycleivesmur', 'Noctule de Leisler / Sérotine bicolore'), ('palaeind', 'Palaeophyllophora sp.'), ('pippippyg', 'Pipistrelle commune / pygmée'), ('pleaurmac', 'Oreillard roux / montagnard'), ('pleausmac', 'Oreillard gris / montagnard'), ('rhidel', 'Rhinolophus delphinensis'), ('rhieurhip', 'Petit rhinolophe / euryale'), ('rhigri', 'Rhinolophus grivensis'), ('rhilis', 'Rhinolophus lissiensis'), ('rousse', 'Roussette sp.'), ('tadind', 'Tadarida sp.'), ('vesant', 'Vespertilio antiqus'), ('vesgri', 'Vespertilio grivensis')], max_length=25, verbose_name='Espèce'),
),
migrations.AlterField(
model_name='sighting',
name='id_fromsrc',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='id unique de la bdd source'),
),
migrations.AlterField(
model_name='sighting',
name='id_sighting',
field=models.AutoField(primary_key=True, serialize=False, verbose_name='id unique'),
),
migrations.AlterField(
model_name='sighting',
name='total_count',
field=models.IntegerField(blank=True, null=True, verbose_name='Nombre total'),
),
migrations.AlterField(
model_name='userdetail',
name='geom',
field=django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=2154, verbose_name='Localisation géographique'),
),
]
This diff is collapsed.
<html>
<p>Hi there!</p>
<p>It works!</p>
</html>
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.place_list, name='place_list'),
]
\ No newline at end of file
from django.shortcuts import render
def place_list(request):
return render(request, 'place_list.html', {})
# Create your views here.
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