Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dbchiro
dbchiroweb
Commits
8c8fd3cb
Commit
8c8fd3cb
authored
Mar 07, 2021
by
hypsug0
Browse files
WIP
parent
1d8d9bc5
Changes
7
Hide whitespace changes
Inline
Side-by-side
.flake8
View file @
8c8fd3cb
[flake8]
ignore = D203, E203, W503, E501
ignore =
E121,
E126,
E127,
E128,
E203,
E225,
E226,
E231,
E241,
E251,
E261,
E265,
E302,
E303,
E305,
E402,
E501,
E741,
W291,
W292,
W293,
W391,
W503,
W504,
F403,
F405,
B007,
B950,
exclude =
.git,
.venv,
...
...
core/static/js/app.js
View file @
8c8fd3cb
...
...
@@ -1173,6 +1173,9 @@ const sigthingFormApp = (id_session) => {
})
}
},
postOneData
(
i
)
{
this
.
postSighting
(
this
.
data
[
i
])
},
postData
()
{
const
callback
=
()
=>
{
this
.
getData
()
...
...
@@ -1235,6 +1238,15 @@ const sigthingFormApp = (id_session) => {
},
},
computed
:
{},
watch
:
{
data
:
()
=>
{
Countsum
=
(
a
,
c
)
=>
a
+
c
.
count
console
.
log
(
'
TEST DATA
'
,
this
.
data
);
this
.
data
.
forEach
(
(
e
,
i
)
=>
this
.
data
[
i
].
total_count
=
this
.
data
[
i
].
countdetails
.
reduce
(
Countsum
,
0
)
)
}
},
mounted
()
{
this
.
getDicts
()
this
.
getData
()
...
...
dbchiro/settings/dev.py
View file @
8c8fd3cb
...
...
@@ -15,9 +15,17 @@ DEV_APPS = ["debug_toolbar"]
INSTALLED_APPS
=
MAIN_APPS
+
DEV_APPS
+
PROJECT_APPS
INTERNAL_IPS
=
[
"127.0.0.1"
,
]
DEBUG_TOOLBAR_CONFIG
=
{
"SHOW_TOOLBAR_CALLBACK"
:
lambda
request
:
True
,
}
# LOGGING_CONFIG = None
format
=
"%(asctime)s %(name)s[%(process)d] %(levelname)s %(message)s"
LOGGING
=
{
"version"
:
1
,
"disable_existing_loggers"
:
True
,
...
...
@@ -45,6 +53,11 @@ LOGGING = {
"level"
:
"WARNING"
,
"propagate"
:
True
,
},
"django"
:
{
"handlers"
:
[
"file"
,
"console"
],
"level"
:
"WARNING"
,
"propagate"
:
True
,
},
"django.requests"
:
{
"handlers"
:
[
"file"
,
"console"
],
"level"
:
"DEBUG"
,
...
...
sights/models.py
View file @
8c8fd3cb
...
...
@@ -1023,7 +1023,6 @@ class Sighting(models.Model):
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
period
=
get_sight_period
(
self
.
session
.
date_start
)
# self.creator = current_user()
super
(
Sighting
,
self
).
save
(
*
args
,
**
kwargs
)
class
Meta
:
...
...
sights/observation/api.py
View file @
8c8fd3cb
...
...
@@ -5,8 +5,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from
rest_framework.generics
import
ListAPIView
from
rest_framework.permissions
import
AllowAny
,
IsAuthenticated
# from rest_framework.permissions import IsAuthenticated
# from rest_framework.response import Response
# from rest_framework.views import APIView
from
rest_framework.viewsets
import
GenericViewSet
,
ModelViewSet
,
mixins
...
...
@@ -19,6 +17,9 @@ from sights.observation.serializers import (
GeoSightingSerializer
,
)
# from rest_framework.permissions import IsAuthenticated
# Get an instance of a logger
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -60,15 +61,13 @@ class EditSighting(ModelViewSet):
qs
=
Sighting
.
objects
.
all
()
return
qs
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
request
.
data
[
"created_by"
]
=
self
.
request
.
user
.
pk
logger
.
debug
(
f
"create data
{
request
.
data
}
"
)
return
super
(
EditSighting
,
self
).
create
(
request
,
*
args
,
**
kwargs
)
def
perform_create
(
self
,
serializer
):
logger
.
debug
(
f
"<perform_create>
\n
SELF:
{
self
}
\n
SERIALIZER
{
serializer
}
"
)
serializer
.
save
(
created_by
=
self
.
request
.
user
)
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
request
.
data
[
"updated_by"
]
=
self
.
request
.
user
.
pk
logger
.
debug
(
f
"update data
{
request
.
data
}
"
)
return
super
().
update
(
request
,
*
args
,
**
kwargs
)
def
perform_update
(
self
,
serializer
):
logger
.
debug
(
f
"<perform_update>
\n
SELF:
{
self
}
\n
SERIALIZER
{
serializer
}
"
)
serializer
.
save
(
updated_by
=
self
.
request
.
user
)
class
DeleteSighting
(
mixins
.
DestroyModelMixin
,
GenericViewSet
):
...
...
@@ -82,12 +81,22 @@ class SessionCountDetailsListView(ModelViewSet):
serializer_class
=
CountDetailSerializer
def
get_queryset
(
self
):
logger
.
debug
(
f
"CALL QUERY
{
self
}
"
)
print
(
f
"CALL QUERY
{
self
}
"
)
if
self
.
action
==
"list"
:
session
=
self
.
kwargs
[
"session"
]
return
CountDetail
.
objects
.
filter
(
sighting__session
=
session
)
else
:
return
CountDetail
.
objects
.
all
()
def
perform_create
(
self
,
serializer
):
logger
.
debug
(
f
"USERRRR
{
self
.
request
.
user
}
{
type
(
self
.
request
.
user
)
}
"
)
serializer
.
save
(
created_by
=
self
.
request
.
user
)
def
perform_update
(
self
,
serializer
):
logger
.
debug
(
f
"USERRRR
{
self
.
request
.
user
}
{
type
(
self
.
request
.
user
)
}
"
)
serializer
.
save
(
updated_by
=
self
.
request
.
user
)
# def get_serializer_class(self):
# return CountDetailSerializer
...
...
sights/observation/serializers.py
View file @
8c8fd3cb
...
...
@@ -224,3 +224,8 @@ class EditSightingSerializerTest(WritableNestedModelSerializer):
"""
countdetails
=
CountDetail
.
objects
.
filter
(
sighting
=
sighting
.
id_sighting
).
all
()
return
countdetails
# def update(self, instance, validated_data):
# logger.debug(f"<update serializer> vd {validated_data}")
# logger.debug(f"<update serializer> instance {instance}")
# return super(EditSightingSerializerTest, self).update(self, instance, validated_data)
templates/sights/sighting_form.html
View file @
8c8fd3cb
...
...
@@ -28,7 +28,7 @@
<div
id=
"spinner"
></div>
</div>
<div
v-else
>
<validation-observer
tag=
"form"
v-slot=
"{ invalid, valid }"
>
<validation-observer
tag=
"form"
v-slot=
"{ invalid, valid }"
slim
>
<form
@
submit.prevent=
"postData"
>
<div
class=
"panel"
:class=
"s.id_sighting ? 'panel-info':'panel-success'"
v-for=
"(s, is) in data"
>
<!-- Default panel contents -->
...
...
@@ -36,8 +36,12 @@
<div
class=
"panel-title"
>
<span
v-if=
"s.id_sighting"
class=
"label label-primary"
>
#[[s.id_sighting]]
</span>
<span
v-else
class=
"badge badge-success"
>
New
</span>
<button
class=
"btn btn-danger btn-xs pull-right"
@
click=
"deleteSighting(is)"
><i
class=
"fa fa-trash"
></i></button>
<div
class=
"btn-group pull-right"
>
<button
class=
"btn btn-info btn-xs pull-right"
@
click=
"postOneData(is)"
><i
class=
"fa fa-save"
></i>
save
</button>
<button
class=
"btn btn-danger btn-xs pull-right"
@
click=
"deleteSighting(is)"
><i
class=
"fa fa-trash"
></i>
del
</button>
</div>
[[ s.codesp ? getSciName(s.codesp):'Choisissez une espèce']]
</div>
</div>
...
...
@@ -55,7 +59,7 @@
[[ sp.sci_name ]]
</option>
</select>
<span
class=
"text-danger help-block"
>
[[ errors[0] ]]
</span>
<span
v-if=
'invalid'
class=
"text-danger help-block"
>
[[ errors[0] ]]
</span>
</div>
</validation-provider>
<div
class=
"form-group"
>
...
...
@@ -115,7 +119,7 @@
v-model:content=
"cd.time"
/>
</div>
<validation-provider
rules=
"required"
immediate
v-slot=
"{ errors, valid, invalid, classes}"
>
v-slot=
"{ errors, valid, invalid, classes}"
slim
>
<div
class=
"form-group"
:class=
'classes'
>
<label
class=
"control-label"
for=
"Method"
>
Méthode
</label>
<select
id=
"Method"
class=
"form-control input-sm"
v-model:title=
"cd.method"
...
...
@@ -125,7 +129,7 @@
[[ method.descr ]]
</option>
</select>
<span
class=
"help-block text-danger"
>
[[ errors[0] ]]
</span>
<span
v-if=
'invalid'
class=
"help-block text-danger"
>
[[ errors[0] ]]
</span>
</div>
</validation-provider>
<div
class=
"col form-group"
>
...
...
@@ -149,8 +153,8 @@
</select>
</div>
<validation-provider
rules=
"required"
immediate
v-slot=
"{ errors, valid, invalid, classes}"
>
<div
class=
"
control-label
"
class=
"form-group"
:class=
'classes'
>
v-slot=
"{ errors, valid, invalid, classes}"
slim
>
<div
class=
"
form-group
"
class=
"form-group"
:class=
'classes'
>
<label
class=
"control-label"
for=
"Precision"
>
Précision
</label>
<select
id=
"Precision"
class=
"form-control input-sm"
v-model:title=
"cd.precision"
v-model:content=
"cd.precision"
...
...
@@ -161,21 +165,21 @@
[[ precision.descr ]]
</option>
</select>
<span
class=
"help-block"
>
[[ errors[0] ]]
</span>
<span
v-if=
'invalid'
class=
"help-block"
>
[[ errors[0] ]]
</span>
</div>
</validation-provider>
<validation-provider
rules=
"required|positive"
immediate
v-slot=
"{ errors, valid, invalid, classes}"
>
v-slot=
"{ errors, valid, invalid, classes}"
slim
>
<div
class=
"form-group"
:class=
"classes"
>
<label
class=
"control-label"
for=
"Count"
>
Dénombrement
</label>
<input
type=
"number"
class=
"form-control input-sm"
class=
"form-control"
id=
"Count"
placeholder=
""
v-model:title=
"cd.count"
required
v-model:content=
"cd.count"
min=
"0"
/>
<span
class=
"help-block"
>
[[ errors[0] ]]
</span>
<span
v-if=
'invalid'
class=
"help-block"
>
[[ errors[0] ]]
</span>
</div>
</validation-provider>
<validation-provider
rules=
"required"
immediate
v-slot=
"{ errors, valid, invalid, classes}"
>
v-slot=
"{ errors, valid, invalid, classes}"
slim
>
<div
class=
"form-group"
:class=
"classes"
>
<label
class=
"control-label"
for=
"Unit"
>
Unité
</label>
<select
id=
"Unit"
class=
"form-control input-sm"
v-model:title=
"cd.unit"
...
...
@@ -185,6 +189,7 @@
[[ unit.descr ]]
</option>
</select>
<span
v-if=
'invalid'
class=
"help-block"
>
[[ errors[0] ]]
</span>
</div>
</validation-provider>
<span
class=
"btn btn-xs pull-right btn-danger"
@
click=
"delCountDetail(is,icd)"
><i
...
...
@@ -201,7 +206,8 @@
<div
class=
"btn-group"
>
<button
@
click=
"addNewSighting()"
class=
"btn btn-success"
><i
class=
"fa fa-plus"
></i>
<strong>
Nouveau
taxon
</strong></button>
<button
type=
"submit"
class=
"btn btn-info"
:class=
"{'btn-warning':invalid,'btn-info':valid}"
:disabled=
"invalid"
><i
class=
"fa fa-plus"
:class=
"{'fa-': invalid}"
></i>
<button
type=
"submit"
class=
"btn btn-info"
:class=
"{'btn-warning':invalid,'btn-info':valid}"
:disabled=
"invalid"
><i
class=
"fa fa-plus"
:class=
"{'fa-': invalid}"
></i>
<strong>
[[invalid ? 'Formulaire non valide': 'Enregistrer']]
</strong></button>
</div>
<button
class=
"btn btn-warning"
@
click=
"showRawData = !showRawData"
>
Raw
</button>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment