forked from kartoza/prj.app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates from develop branch (kartoza#395)
* Fix menu (kartoza#357) * Add custom render dashboard (kartoza#359) * Add int and float types in csv upload (kartoza#360) * Fix bugs in layer selector order (kartoza#363) * Fix unsaved selected layer not displayed (kartoza#364) * Add api to get non validated records for sidepanel validation later (kartoza#365) * Api to get non validated records * Add tests for unvalidated records api * Generate permission by taxon class (kartoza#366) * Get allowed collections based on permission (kartoza#368) * Fix selector bugs (kartoza#370) * Update validate records page (kartoza#371) * Fix send email to validator (kartoza#373) * Fix legend is covered (kartoza#375) * Fix biodiversity legend bug (kartoza#376) * Spatial filter (kartoza#374) * Add spatial filter panel button * User boundary model * Add upload functionality in modal * Backend for upload user boundary shapefile * Show boundary list and add click event * Search by user boundary * Add boundary name input * Select multiple boundary * Add clear and apply filter * Update search * Add search mode flag * Make marker still clickable * Remove console log * Update production requirements (kartoza#377) * Fix spatial search for location site (kartoza#381) * Fix search user_boundaries * Fix reset search (kartoza#383) * Add coming soon menu (kartoza#382) * Fix spatial search if site outside boundary (kartoza#384) * Additional filters (kartoza#385) * Optional filters * Fix tests * Add new fields to collection models (kartoza#386) * Add new fields to collection models * Add migration file * Add site code to location site * Update csv upload to accomodate new fields * Add missing migration * Fix tests * Fix flake8 * Fix filter not working (kartoza#387) * Add reference category filter (kartoza#388) * Add api to get the reference category * Show reference category lists in filter panel * Filter function with reference category * Fix travis * Fix missing variable (kartoza#389) * Fix csv uploads (kartoza#390) * Update location site model (kartoza#391) * Validation ui (kartoza#392) * Show validation list in front end * Show point on map * Show and hide detail * Add validate function * Return pagination information * Update layout * Fix layout * Clear point in fetch collection * Fix travis * Fix side panel behavior * Only show validate button to user who has permission * Add compiled js * Fix get key function (kartoza#393) * Set search panel title in settings (kartoza#394)
- Loading branch information
1 parent
d03c88c
commit cbfae7e
Showing
64 changed files
with
2,322 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# coding=utf-8 | ||
from django.http.response import HttpResponse | ||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | ||
from rest_framework.views import APIView, Response | ||
from rest_framework import status | ||
from bims.models.biological_collection_record import BiologicalCollectionRecord | ||
from bims.serializers.bio_collection_serializer import ( | ||
BioCollectionSerializer, | ||
) | ||
from bims.permissions.api_permission import IsValidator, AllowedTaxon | ||
|
||
|
||
class GetNonValidatedRecords(APIView): | ||
|
||
permission_classes = [IsValidator, ] | ||
page_limit = 5 | ||
|
||
def get(self, request): | ||
try: | ||
allowed_taxon = AllowedTaxon() | ||
taxon_list = allowed_taxon.get(request.user) | ||
records = BiologicalCollectionRecord.objects.filter( | ||
validated=False, | ||
ready_for_validation=True, | ||
taxon_gbif_id__in=taxon_list | ||
) | ||
|
||
paginator = Paginator(records, self.page_limit) | ||
page = request.GET.get('page') | ||
|
||
try: | ||
records = paginator.page(page) | ||
current_page = int(page) | ||
except PageNotAnInteger: | ||
records = paginator.page(1) | ||
current_page = 1 | ||
except EmptyPage: | ||
records = paginator.page(paginator.num_pages) | ||
current_page = paginator.num_pages | ||
|
||
serializer = BioCollectionSerializer( | ||
records, | ||
many=True | ||
) | ||
response_data = { | ||
'data': serializer.data, | ||
'pagination': { | ||
'current_page': current_page, | ||
'max_page': paginator.num_pages, | ||
'page_limit': self.page_limit | ||
} | ||
} | ||
return Response(response_data) | ||
except BiologicalCollectionRecord.DoesNotExist: | ||
return HttpResponse( | ||
'Object Does Not Exist', | ||
status=status.HTTP_400_BAD_REQUEST | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# coding=utf-8 | ||
from django.db.models import Q | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
from bims.models.biological_collection_record import BiologicalCollectionRecord | ||
|
||
|
||
class ReferenceCategoryList(APIView): | ||
"""Return list of reference category""" | ||
def get(self, request, *args): | ||
reference_category = \ | ||
BiologicalCollectionRecord.objects.filter( | ||
~Q(reference_category='') & Q(validated=True)).\ | ||
values_list( | ||
'reference_category', flat=True).\ | ||
distinct() | ||
results = [] | ||
for reference in reference_category: | ||
results.append( | ||
{ | ||
'category': reference | ||
} | ||
) | ||
return Response(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# coding=utf-8 | ||
from rest_framework.response import Response | ||
from rest_framework.views import APIView | ||
from bims.models.user_boundary import UserBoundary | ||
from bims.serializers.boundary_serializer import UserBondarySerializer | ||
|
||
|
||
class UserBoundaryList(APIView): | ||
"""API for listing boundary.""" | ||
|
||
def get(self, request, *args): | ||
boundaries = UserBoundary.objects.filter( | ||
user=request.user | ||
) | ||
serializer = UserBondarySerializer(boundaries, many=True) | ||
return Response(serializer.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.core.management.base import BaseCommand | ||
from bims.permissions.generate_permission import generate_permission | ||
from bims.models.taxon import Taxon | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Generate permissions for all taxon class | ||
""" | ||
|
||
def handle(self, *args, **options): | ||
taxa = Taxon.objects.all().values('taxon_class').distinct() | ||
for taxon in taxa: | ||
generate_permission(taxon['taxon_class']) |
Oops, something went wrong.