Commit fc3d8c6b authored by Hypsug0's avatar Hypsug0
Browse files

Add buttons to home page

parent fbe655d0
......@@ -145,7 +145,7 @@ bcrypt = ["bcrypt"]
[[package]]
name = "django-autocomplete-light"
version = "3.8.1"
version = "3.5.1"
description = "Fresh autocompletes for Django"
category = "main"
optional = false
......@@ -781,7 +781,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake
[metadata]
lock-version = "1.1"
python-versions = "^3.6"
content-hash = "744be7a022b72f516817713dbfcad593b94179e2eaf51ce6876610525c79128d"
content-hash = "d89d150a317616ec1010ccdb249f6aaecd44b4cdb37b12c848e9659f4a581403"
[metadata.files]
appdirs = [
......@@ -836,7 +836,7 @@ django = [
{file = "Django-2.2.17.tar.gz", hash = "sha256:cf5370a4d7765a9dd6d42a7b96b53c74f9446cd38209211304b210fe0404b861"},
]
django-autocomplete-light = [
{file = "django-autocomplete-light-3.8.1.tar.gz", hash = "sha256:4e84a6d95d272b0d7221614332e2bd54ffff15ec06e78947279398f6507ce225"},
{file = "django-autocomplete-light-3.5.1.tar.gz", hash = "sha256:52e8d468060a5911c44300a374d74058c90e65bfdf87ace151abac67279c4ae5"},
]
django-ckeditor = [
{file = "django-ckeditor-6.0.0.tar.gz", hash = "sha256:29fd1a333cb9741ac2c3fd4e427a5c00115ed33a2389716a09af7656022dcdde"},
......
......@@ -9,7 +9,6 @@ license = "AGPLv3"
[tool.poetry.dependencies]
python = "^3.6"
Django = "^2.2.17"
django-autocomplete-light = "^3.8.1"
djangorestframework-gis = "^0.16"
django-crispy-forms = "^1.10.0"
django-filter = "^2.4"
......@@ -26,6 +25,7 @@ arrow = "^0.17.0"
Pillow = "^8.1.0"
drf-yasg = "^1.20.0"
gunicorn = "^20.0.4"
django-autocomplete-light = "3.5.1"
[tool.poetry.dev-dependencies]
django-debug-toolbar = "^3.2"
......
import logging
from rest_framework import serializers
from dicts.models import (
Age,
BiomChinspot,
BiomDent,
BiomEpiphyse,
BiomEpipidyme,
BiomGestation,
BiomGlandCoul,
BiomGlandTaille,
BiomMamelle,
BiomTesticule,
BiomTuniqVag,
CountPrecision,
CountUnit,
Method,
Sex,
)
from geodata.models import Municipality
from sights.models import CountDetail
logger = logging.getLogger(__name__)
dict_fields = ("id", "code")
# class DictBaseSerializer(serializers.ModelSerializer):
# class Meta:
# model = None
# fields = dict_fields = ("id", "code")
class AgeSerializer(serializers.ModelSerializer):
class Meta:
model = Age
fields = dict_fields
class BiomChinspotSerializer(serializers.ModelSerializer):
class Meta:
model = BiomChinspot
fields = dict_fields
class BiomDentSerializer(serializers.ModelSerializer):
class Meta:
model = BiomDent
fields = dict_fields
class CountPrecisionSerializer(serializers.ModelSerializer):
class Meta:
model = CountPrecision
fields = dict_fields
class CountPrecisionSerializer(serializers.ModelSerializer):
class Meta:
model = CountPrecision
fields = dict_fields
class CountDetailSerializer(serializers.ModelSerializer):
# precision = CountPrecisionSerializer()
# age = AgeSerializer()
# usure_dents = BiomDent()
class Meta:
model = CountDetail
fields = (
"id_countdetail",
"method",
"sex",
"age",
"precision",
"count",
"unit",
"time",
"device",
"manipulator",
"validator",
"transmitter",
"ab",
"d5",
"pouce",
"queue",
"tibia",
"pied",
"cm3",
"tragus",
"poids",
"testicule",
"epididyme",
"tuniq_vag",
"gland_taille",
"gland_coul",
"mamelle",
"gestation",
"epiphyse",
"chinspot",
"etat_sexuel",
"usure_dent",
"comment",
)
......@@ -3,19 +3,23 @@ import logging
from django.contrib.auth.mixins import LoginRequiredMixin
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
from sights.mixins import (
LargeGeoJsonPageNumberPagination,
SightingFilteredListWithPermissions,
)
from sights.observation.serializers import SightingSerializer
from sights.mixins import LargeGeoJsonPageNumberPagination, SightingFilteredListWithPermissions
from sights.models import CountDetail, Sighting
from sights.observation.serializers import EditSightingSerializer, SightingSerializer
# Get an instance of a logger
logger = logging.getLogger(__name__)
class GeoJSONSighting(
LoginRequiredMixin, SightingFilteredListWithPermissions, generics.ListAPIView,
LoginRequiredMixin,
SightingFilteredListWithPermissions,
generics.ListAPIView,
):
serializer_class = SightingSerializer
pagination_class = LargeGeoJsonPageNumberPagination
......@@ -33,3 +37,30 @@ class GeoJSONSighting(
)
return qs.distinct().order_by("-timestamp_update")
class EditSighting(ModelViewSet):
serializer_class = EditSightingSerializer
# permission_class = [IsAuthenticated]
def get_queryset(self):
session = self.kwargs["session"]
return Sighting.objects.filter(session=session)
# def list(self, request, *args, **kwargs):
# queryset = self.filter_queryset(self.get_queryset())
# session = self.kwargs["session"]
# queryset = Sighting.objects.filter(session=session).order_by("-timestamp_update")
# serializer = EditSightingSerializer(queryset, many=True)
# return Response(serializer.data)
# return Response(serializer.data)
# def get(self, request, pk=None):
# """
# Return a session observations.
# """
# obs = [user.username for user in Sighting.objects.all()]
# user = get_object_or_404(queryset, pk=pk)
# serializer = UserSerializer(user)
# return Response(serializer.data)
# return Response(obs)
from rest_framework_gis import serializers
from rest_framework.serializers import SerializerMethodField
from rest_framework_gis import serializers
from accounts.models import Profile
from dicts.models import Specie, Contact
from dicts.models import Contact, Specie
from geodata.models import Municipality
from sights.models import Place, Session, Sighting, CountDetail
from sights.countdetail.serializers import CountDetailSerializer
from sights.models import CountDetail, Place, Session, Sighting
class SightingSpecie(serializers.ModelSerializer):
......@@ -86,3 +88,27 @@ class SightingSerializer(serializers.GeoFeatureModelSerializer):
# def get_countdetail(self, sighting):
# countdetails = CountDetail.objects.filter(sighting=sighting.id_sighting).all()
# return countdetails
class EditSightingSerializer(serializers.ModelSerializer):
"""Sighting serializer for editing data (insert/update) from sighting and count details model"""
# countdetail_sighting = CountDetailSerializer(many=True)
class Meta:
model = Sighting
fields = (
"id_sighting",
"codesp",
"breed_colo",
"total_count",
"observer",
"is_doubtful",
"comment",
"extra_data",
"countdetail_sighting",
)
def get_countdetail_sighting(self, sighting):
countdetails = CountDetail.objects.filter(sighting=sighting.id_sighting).all()
return countdetails
from django.contrib.auth.decorators import login_required
from django.urls import include, path
from django.views.generic import TemplateView
from sights.observation.api import GeoJSONSighting
from sights.observation.api import EditSighting, GeoJSONSighting
from sights.observation.views import (
SightingCreate,
SightingDelete,
SightingDetail,
SightingMyList,
SightingUpdate,
SightingSearch,
SightingUpdate,
)
urlpatterns = [
......@@ -23,5 +23,10 @@ urlpatterns = [
path("sighting/<int:pk>/update", SightingUpdate.as_view(), name="sighting_update"),
path("sighting/<int:pk>/delete", SightingDelete.as_view(), name="sighting_delete"),
path("sighting/api/search", GeoJSONSighting.as_view(), name="sighting_search_api"),
path(
"api/v1/session/<int:session>/sightings",
EditSighting.as_view({"get": "list"}),
name="sighting_detail_api",
),
path("sighting/search", SightingSearch.as_view(), name="sighting_search"),
]
......@@ -32,6 +32,18 @@
</div>
</div>
</div>
<div class="row" style="text-align:center;font-size:2rem;">
<div class="col-xs-12 col-sm-6">
<a href="{% url 'sights:place_search' %}" class="btn btn-success btn-lg btn-block">
<i class="fa fa-map"></i> Rechercher des localités / Saisir
</a>
</div>
<div class="col-xs-12 col-sm-6">
<a href="{% url 'sights:sighting_mylist' %}" class="btn btn-warning btn-lg btn-block">
<i class="fa fa-user"></i> Mes observations
</a>
</div>
</div>
<h1>
<i class="{{ icon | safe }}"></i> {{ title }}
</h1>
......
Supports Markdown
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