From d944499b53b66f6d9b30e17e103cbec689188876 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 14:56:25 +0100 Subject: [PATCH 01/16] Removing irrelevant `album` and `tracks` --- ...ue_together_remove_track_album_and_more.py | 27 +++ seshat/apps/seshat_api/views.py | 164 ------------------ 2 files changed, 27 insertions(+), 164 deletions(-) create mode 100644 seshat/apps/seshat_api/migrations/0002_alter_track_unique_together_remove_track_album_and_more.py delete mode 100644 seshat/apps/seshat_api/views.py diff --git a/seshat/apps/seshat_api/migrations/0002_alter_track_unique_together_remove_track_album_and_more.py b/seshat/apps/seshat_api/migrations/0002_alter_track_unique_together_remove_track_album_and_more.py new file mode 100644 index 000000000..358baf76f --- /dev/null +++ b/seshat/apps/seshat_api/migrations/0002_alter_track_unique_together_remove_track_album_and_more.py @@ -0,0 +1,27 @@ +# Generated by Django 4.0.3 on 2024-06-20 19:25 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('seshat_api', '0001_initial'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='track', + unique_together=None, + ), + migrations.RemoveField( + model_name='track', + name='album', + ), + migrations.DeleteModel( + name='Album', + ), + migrations.DeleteModel( + name='Track', + ), + ] diff --git a/seshat/apps/seshat_api/views.py b/seshat/apps/seshat_api/views.py deleted file mode 100644 index 6fae45490..000000000 --- a/seshat/apps/seshat_api/views.py +++ /dev/null @@ -1,164 +0,0 @@ -from django.contrib.auth.models import User, Group -from django.views.decorators.csrf import csrf_exempt -from rest_framework import generics, viewsets, permissions -from rest_framework.parsers import JSONParser -from rest_framework.decorators import api_view -from rest_framework import status - - -from django.http import HttpResponse, JsonResponse - -#from django.http import HttpResponse -from ..core.models import Polity, Reference, Section -from .serializers import UserSerializer, GroupSerializer, PolitySerializer, ReferenceSerializer - -from .models import Album, Track - -#from .serializers import PolitySerializer -# Create your views here. - - -class UserViewSet(viewsets.ModelViewSet): - """ - API endpoint that allows users to be viewed or edited. - """ - queryset = User.objects.all().order_by('-date_joined') - serializer_class = UserSerializer - permission_classes = [permissions.IsAuthenticatedOrReadOnly] - - -class GroupViewSet(viewsets.ModelViewSet): - """ - API endpoint that allows groups to be viewed or edited. - """ - queryset = Group.objects.all() - serializer_class = GroupSerializer - permission_classes = [permissions.IsAuthenticatedOrReadOnly] - - -class PolityViewSet(viewsets.ModelViewSet): - """ - API endpoint that allows Politys to be viewed or edited. - """ - queryset = Polity.objects.all() - serializer_class = PolitySerializer - permission_classes = [permissions.IsAuthenticatedOrReadOnly] - - -# class SectionViewSet(viewsets.ModelViewSet): -# """ -# API endpoint that allows groups to be viewed or edited. -# """ -# queryset = Section.objects.all() -# serializer_class = SectionSerializer -# permission_classes = [permissions.IsAuthenticatedOrReadOnly] - - -@api_view(['GET', 'POST']) -def reference_list(request, format=None): - """ - List all references, or create a new reference. - """ - if request.method == 'GET': - refs = Reference.objects.all() - serializer = ReferenceSerializer(refs, many=True) - return JsonResponse(serializer.data, safe=False) - - elif request.method == 'POST': - # data = JSONParser().parse(request) - serializer = ReferenceSerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - return JsonResponse(serializer.data, status=status.HTTP_201_CREATED) - return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - -@api_view(['GET', 'PUT', 'DELETE']) -def reference_detail(request, pk, format=None): - """ - Retrieve, update or delete a reference. - """ - try: - ref = Reference.objects.get(pk=pk) - except Reference.DoesNotExist: - return HttpResponse(status=status.HTTP_404_NOT_FOUND) - - if request.method == 'GET': - serializer = ReferenceSerializer(ref) - return JsonResponse(serializer.data) - - elif request.method == 'PUT': - #data = JSONParser().parse(request) - serializer = ReferenceSerializer(ref, data=request.data) - if serializer.is_valid(): - serializer.save() - return JsonResponse(serializer.data) - return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - elif request.method == 'DELETE': - ref.delete() - return HttpResponse(status=status.HTTP_204_NO_CONTENT) - - -@api_view(['GET', 'POST']) -def album_list(request, format=None): - """ - List all Albums, or create a new Album. - """ - if request.method == 'GET': - refs = Album.objects.all() - serializer = AlbumSerializer(refs, many=True) - return JsonResponse(serializer.data, safe=False) - - elif request.method == 'POST': - # data = JSONParser().parse(request) - serializer = AlbumSerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - return JsonResponse(serializer.data, status=status.HTTP_201_CREATED) - return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - -@api_view(['GET', 'PUT', 'DELETE']) -def album_detail(request, pk, format=None): - """ - Retrieve, update or delete a album. - """ - try: - ref = Album.objects.get(pk=pk) - except Album.DoesNotExist: - return HttpResponse(status=status.HTTP_404_NOT_FOUND) - - if request.method == 'GET': - serializer = AlbumSerializer(ref) - return JsonResponse(serializer.data) - - elif request.method == 'PUT': - #data = JSONParser().parse(request) - serializer = AlbumSerializer(ref, data=request.data) - if serializer.is_valid(): - serializer.save() - return JsonResponse(serializer.data) - return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - elif request.method == 'DELETE': - ref.delete() - return HttpResponse(status=status.HTTP_204_NO_CONTENT) - -# def VarDetail(): -# pass - - -# def VarList(request): -# return HttpResponse('

Hello World from api.

') - - -# class PolityList(generics.ListCreateAPIView): -# queryset = Polity.objects.all() -# serializer_class = PolitySerializer -# pass - - -# class PolityDetail(generics.RetrieveDestroyAPIView): -# queryset = Polity.objects.all() -# serializer_class = PolitySerializer From e1eee3caf886e34e59a28a2ca5c4f9164343b4ce Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 14:56:48 +0100 Subject: [PATCH 02/16] Removing `Track` and `Album` models from admin registration --- seshat/apps/seshat_api/admin.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/seshat/apps/seshat_api/admin.py b/seshat/apps/seshat_api/admin.py index c159eb4c6..e69de29bb 100644 --- a/seshat/apps/seshat_api/admin.py +++ b/seshat/apps/seshat_api/admin.py @@ -1,6 +0,0 @@ -from django.contrib import admin - -from .models import Track, Album - -admin.site.register(Track) -admin.site.register(Album) From ed0b293d769cb61bda5f483083c55e1dae65a243 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 14:57:25 +0100 Subject: [PATCH 03/16] Dropping `Album` and `Track` models --- seshat/apps/seshat_api/models.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/seshat/apps/seshat_api/models.py b/seshat/apps/seshat_api/models.py index 4ea35ad63..e69de29bb 100644 --- a/seshat/apps/seshat_api/models.py +++ b/seshat/apps/seshat_api/models.py @@ -1,21 +0,0 @@ -from django.db import models - - -class Album(models.Model): - album_name = models.CharField(max_length=100) - artist = models.CharField(max_length=100) - - -class Track(models.Model): - album = models.ForeignKey( - Album, related_name='tracks', on_delete=models.CASCADE) - order = models.IntegerField() - title = models.CharField(max_length=100) - duration = models.IntegerField() - - class Meta: - unique_together = ['album', 'order'] - ordering = ['order'] - - def __str__(self): - return '%d: %s' % (self.order, self.title) From 54d14f46764becd94764f4556168b5affcfa14fa Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:01:24 +0100 Subject: [PATCH 04/16] Adding in API views --- seshat/apps/seshat_api/views/__init__.py | 1 + seshat/apps/seshat_api/views/_mixins.py | 57 ++ seshat/apps/seshat_api/views/_permissions.py | 11 + seshat/apps/seshat_api/views/accounts.py | 45 + seshat/apps/seshat_api/views/core.py | 289 ++++++ seshat/apps/seshat_api/views/crisisdb.py | 307 +++++++ seshat/apps/seshat_api/views/general.py | 296 +++++++ seshat/apps/seshat_api/views/rt.py | 241 +++++ seshat/apps/seshat_api/views/sc.py | 873 +++++++++++++++++++ seshat/apps/seshat_api/views/wf.py | 555 ++++++++++++ 10 files changed, 2675 insertions(+) create mode 100644 seshat/apps/seshat_api/views/__init__.py create mode 100644 seshat/apps/seshat_api/views/_mixins.py create mode 100644 seshat/apps/seshat_api/views/_permissions.py create mode 100644 seshat/apps/seshat_api/views/accounts.py create mode 100644 seshat/apps/seshat_api/views/core.py create mode 100644 seshat/apps/seshat_api/views/crisisdb.py create mode 100644 seshat/apps/seshat_api/views/general.py create mode 100644 seshat/apps/seshat_api/views/rt.py create mode 100644 seshat/apps/seshat_api/views/sc.py create mode 100644 seshat/apps/seshat_api/views/wf.py diff --git a/seshat/apps/seshat_api/views/__init__.py b/seshat/apps/seshat_api/views/__init__.py new file mode 100644 index 000000000..005159426 --- /dev/null +++ b/seshat/apps/seshat_api/views/__init__.py @@ -0,0 +1 @@ +# Keep file to ensure Python treats the directory as a package \ No newline at end of file diff --git a/seshat/apps/seshat_api/views/_mixins.py b/seshat/apps/seshat_api/views/_mixins.py new file mode 100644 index 000000000..49ac8130f --- /dev/null +++ b/seshat/apps/seshat_api/views/_mixins.py @@ -0,0 +1,57 @@ +from rest_framework.pagination import PageNumberPagination +from rest_framework.permissions import IsAuthenticated, AllowAny + +from ..serializers import GeneralSerializer +from rest_framework.serializers import HyperlinkedRelatedField + +STANDARD_API_AUTHENTICATION = { + "HEAD": [AllowAny], + "OPTIONS": [AllowAny], + "GET": [AllowAny], + "POST": [IsAuthenticated], + "PUT": [IsAuthenticated], + "PATCH": [IsAuthenticated], + "DELETE": [IsAuthenticated], +} +"""Defines the standard authentication for the API, if no other is specified in the view.""" + + +class SeshatAPIPagination(PageNumberPagination): + """ + Custom pagination class for the API. + """ + page_size = 10 + page_size_query_param = "page_size" + max_page_size = 100 + + +class MixinSeshatAPIAuth: + """ + Mixin class to set the authentication classes for the API. + """ + def get_permissions(self): + try: + permissions_dict = self.permissions_dict + except AttributeError: + permissions_dict = STANDARD_API_AUTHENTICATION + + return [ + permission() + for permission in permissions_dict[self.request.method] + ] + +class MixinSeshatAPISerializer: + def get_serializer_class(self): + # Set model to self.model + GeneralSerializer.Meta.model = self.model + + # Set fields to self.fields + try: + GeneralSerializer.Meta.fields = self.fields + except AttributeError: + GeneralSerializer.Meta.fields = "__all__" + + return GeneralSerializer + + def get_queryset(self): + return self.model.objects.all() diff --git a/seshat/apps/seshat_api/views/_permissions.py b/seshat/apps/seshat_api/views/_permissions.py new file mode 100644 index 000000000..32f5e04da --- /dev/null +++ b/seshat/apps/seshat_api/views/_permissions.py @@ -0,0 +1,11 @@ +from rest_framework.permissions import IsAdminUser + +ONLY_ADMIN_PERMISSIONS = { + "HEAD": [IsAdminUser], + "OPTIONS": [IsAdminUser], + "GET": [IsAdminUser], + "POST": [IsAdminUser], + "PUT": [IsAdminUser], + "PATCH": [IsAdminUser], + "DELETE": [IsAdminUser], +} diff --git a/seshat/apps/seshat_api/views/accounts.py b/seshat/apps/seshat_api/views/accounts.py new file mode 100644 index 000000000..dca7ff447 --- /dev/null +++ b/seshat/apps/seshat_api/views/accounts.py @@ -0,0 +1,45 @@ +from rest_framework import viewsets + +from ...accounts.models import Profile, Seshat_Expert, Seshat_Task + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, +) +from ._permissions import ONLY_ADMIN_PERMISSIONS + + +class ProfileViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ReadOnlyModelViewSet +): + """ + A viewset for viewing user profiles. + """ + + model = Profile + lookup_field = "user__username" + permissions_dict = ONLY_ADMIN_PERMISSIONS + + +class SeshatExpertViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Experts. + """ + + model = Seshat_Expert + lookup_field = "user__username" + permissions_dict = ONLY_ADMIN_PERMISSIONS + + +class SeshatTaskViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ReadOnlyModelViewSet +): + """ + A viewset for viewing Seshat Tasks. + """ + + model = Seshat_Task + permissions_dict = ONLY_ADMIN_PERMISSIONS + fields = "__all__" diff --git a/seshat/apps/seshat_api/views/core.py b/seshat/apps/seshat_api/views/core.py new file mode 100644 index 000000000..51c3f5959 --- /dev/null +++ b/seshat/apps/seshat_api/views/core.py @@ -0,0 +1,289 @@ +from rest_framework import viewsets + +from ._permissions import ONLY_ADMIN_PERMISSIONS + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + +from ...core.models import ( + SeshatPrivateComment, + SeshatPrivateCommentPart, + Macro_region, + Seshat_region, + Nga, + Polity, + Capital, + Ngapolityrel, + Country, + Section, + Subsection, + Variablehierarchy, + Reference, + Citation, + SeshatComment, + SeshatCommentPart, + ScpThroughCtn, + SeshatCommon, + Religion, + VideoShapefile, + GADMShapefile, + GADMCountries, + GADMProvinces, +) + + +class PrivateCommentsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Private Comments. + """ + + model = SeshatPrivateComment + pagination_class = SeshatAPIPagination + permissions_dict = ONLY_ADMIN_PERMISSIONS + + +class PrivateCommentsPartsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Private Comment Parts. + """ + + model = SeshatPrivateCommentPart + pagination_class = SeshatAPIPagination + permissions_dict = ONLY_ADMIN_PERMISSIONS + + +class MacroRegionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Macro Regions. + """ + + model = Macro_region + pagination_class = SeshatAPIPagination + + +class RegionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Regions. + """ + + model = Seshat_region + pagination_class = SeshatAPIPagination + + +class NGAViewSet(MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet): + """ + A viewset for viewing and editing NGA. + """ + + model = Nga + pagination_class = SeshatAPIPagination + + +class PolityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polities. + """ + + model = Polity + pagination_class = SeshatAPIPagination + + +class CapitalViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Capitals. + """ + + model = Capital + pagination_class = SeshatAPIPagination + + +class NGAPolityRelationsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing NGA Polity Relations. + """ + + model = Ngapolityrel + pagination_class = SeshatAPIPagination + + +class CountryViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Countries. + """ + + model = Country + pagination_class = SeshatAPIPagination + + +class SectionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Sections. + """ + + model = Section + pagination_class = SeshatAPIPagination + + +class SubsectionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Subsections. + """ + + model = Subsection + pagination_class = SeshatAPIPagination + + +class VariableHierarchyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Variable Hierarchies. + """ + + model = Variablehierarchy + pagination_class = SeshatAPIPagination + + +class ReferenceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing References. + """ + + model = Reference + pagination_class = SeshatAPIPagination + + +class CitationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Citations. + """ + + model = Citation + pagination_class = SeshatAPIPagination + + +class SeshatCommentViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Comments. + """ + + model = SeshatComment + pagination_class = SeshatAPIPagination + + +class SeshatCommentPartViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Comment Parts. + """ + + model = SeshatCommentPart + pagination_class = SeshatAPIPagination + + +class ScpThroughCtnViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Comment Parts' relations to + Citations. + """ + + model = ScpThroughCtn + pagination_class = SeshatAPIPagination + + +class SeshatCommonViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Seshat Common. + """ + + model = SeshatCommon + pagination_class = SeshatAPIPagination + + +class ReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Religions. + """ + + model = Religion + pagination_class = SeshatAPIPagination + + +class VideoShapefileViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Video Shapefiles. + """ + + model = VideoShapefile + pagination_class = SeshatAPIPagination + + +class GADMShapefileViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing GADM Shapefiles. + """ + + model = GADMShapefile + pagination_class = SeshatAPIPagination + + +class GADMCountriesViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing GADM Countries. + """ + + model = GADMCountries + pagination_class = SeshatAPIPagination + + +class GADMProvincesViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing GADM Provinces. + """ + + model = GADMProvinces + pagination_class = SeshatAPIPagination diff --git a/seshat/apps/seshat_api/views/crisisdb.py b/seshat/apps/seshat_api/views/crisisdb.py new file mode 100644 index 000000000..0df805940 --- /dev/null +++ b/seshat/apps/seshat_api/views/crisisdb.py @@ -0,0 +1,307 @@ +from rest_framework import viewsets + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + +from ...crisisdb.models import ( + Us_location, + Us_violence_subtype, + Us_violence_data_source, + Us_violence, + Crisis_consequence, + Power_transition, + Human_sacrifice, + External_conflict, + Internal_conflict, + External_conflict_side, + Agricultural_population, + Arable_land, + Arable_land_per_farmer, + Gross_grain_shared_per_agricultural_population, + Net_grain_shared_per_agricultural_population, + Surplus, + Military_expense, + Silver_inflow, + Silver_stock, + Total_population, + Gdp_per_capita, + Drought_event, + Locust_event, + Socioeconomic_turmoil_event, + Crop_failure_event, + Famine_event, + Disease_outbreak, +) + + +class USLocationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing US Locations. + """ + model = Us_location + pagination_class = SeshatAPIPagination + + +class USViolenceSubtypeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing US Violence Subtypes. + """ + model = Us_violence_subtype + pagination_class = SeshatAPIPagination + + +class USViolenceDataSourceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing US Violence Data Sources. + """ + model = Us_violence_data_source + pagination_class = SeshatAPIPagination + + +class USViolenceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing US Violence. + """ + model = Us_violence + pagination_class = SeshatAPIPagination + + +class CrisisConsequenceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Crisis Consequences. + """ + model = Crisis_consequence + pagination_class = SeshatAPIPagination + + +class PowerTransitionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Power Transitions. + """ + model = Power_transition + pagination_class = SeshatAPIPagination + + +class HumanSacrificeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Human Sacrifices. + """ + model = Human_sacrifice + pagination_class = SeshatAPIPagination + + +class ExternalConflictViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing External Conflicts. + """ + model = External_conflict + pagination_class = SeshatAPIPagination + + +class InternalConflictViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Internal Conflicts. + """ + model = Internal_conflict + pagination_class = SeshatAPIPagination + + +class ExternalConflictSideViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing External Conflict Sides. + """ + model = External_conflict_side + pagination_class = SeshatAPIPagination + + +class AgriculturalPopulationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Agricultural Populations. + """ + model = Agricultural_population + pagination_class = SeshatAPIPagination + + +class ArableLandViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Arable Lands. + """ + model = Arable_land + pagination_class = SeshatAPIPagination + + +class ArableLandPerFarmerViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Arable Land Per Farmers. + """ + model = Arable_land_per_farmer + pagination_class = SeshatAPIPagination + + +class GrossGrainSharedPerAgriculturalPopulationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gross Grain Shared Per Agricultural Populations. + """ + model = Gross_grain_shared_per_agricultural_population + pagination_class = SeshatAPIPagination + + +class NetGrainSharedPerAgriculturalPopulationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Net Grain Shared Per Agricultural Populations. + """ + model = Net_grain_shared_per_agricultural_population + pagination_class = SeshatAPIPagination + + +class SurplusViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Surpluses. + """ + model = Surplus + pagination_class = SeshatAPIPagination + + +class MilitaryExpenseViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Military Expenses. + """ + model = Military_expense + pagination_class = SeshatAPIPagination + + +class SilverInflowViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Silver Inflows. + """ + model = Silver_inflow + pagination_class = SeshatAPIPagination + + +class SilverStockViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Silver Stocks. + """ + model = Silver_stock + pagination_class = SeshatAPIPagination + + +class TotalPopulationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Total Populations. + """ + model = Total_population + pagination_class = SeshatAPIPagination + + +class GDPPerCapitaViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing GDP Per Capitas. + """ + model = Gdp_per_capita + pagination_class = SeshatAPIPagination + + +class DroughtEventViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Drought Events. + """ + model = Drought_event + pagination_class = SeshatAPIPagination + + +class LocustEventViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Locust Events. + """ + model = Locust_event + pagination_class = SeshatAPIPagination + + +class SocioeconomicTurmoilEventViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Socioeconomic Turmoil Events. + """ + model = Socioeconomic_turmoil_event + pagination_class = SeshatAPIPagination + + +class CropFailureEventViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Crop Failure Events. + """ + model = Crop_failure_event + pagination_class = SeshatAPIPagination + + +class FamineEventViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Famine Events. + """ + model = Famine_event + pagination_class = SeshatAPIPagination + + +class DiseaseOutbreakViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Disease Outbreaks. + """ + model = Disease_outbreak + pagination_class = SeshatAPIPagination diff --git a/seshat/apps/seshat_api/views/general.py b/seshat/apps/seshat_api/views/general.py new file mode 100644 index 000000000..c50bf9777 --- /dev/null +++ b/seshat/apps/seshat_api/views/general.py @@ -0,0 +1,296 @@ +from rest_framework import viewsets + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + +from ...general.models import ( + Polity_research_assistant, + Polity_original_name, + Polity_alternative_name, + Polity_duration, + Polity_peak_years, + Polity_degree_of_centralization, + Polity_suprapolity_relations, + Polity_utm_zone, + Polity_capital, + Polity_language, + Polity_linguistic_family, + Polity_language_genus, + Polity_religion_genus, + Polity_religion_family, + Polity_religion, + Polity_relationship_to_preceding_entity, + Polity_preceding_entity, + Polity_succeeding_entity, + Polity_supracultural_entity, + Polity_scale_of_supracultural_interaction, + Polity_alternate_religion_genus, + Polity_alternate_religion_family, + Polity_alternate_religion, + Polity_expert, + Polity_editor, + Polity_religious_tradition, +) + + +class PolityResearchAssistantViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Research Assistants. + """ + model = Polity_research_assistant + pagination_class = SeshatAPIPagination + + +class PolityOriginalNameViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Original Names. + """ + model = Polity_original_name + pagination_class = SeshatAPIPagination + + +class PolityAlternativeNameViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Alternative Names. + """ + model = Polity_alternative_name + pagination_class = SeshatAPIPagination + + +class PolityDurationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Durations. + """ + model = Polity_duration + pagination_class = SeshatAPIPagination + + +class PolityPeakYearsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Peak Years. + """ + model = Polity_peak_years + pagination_class = SeshatAPIPagination + + +class PolityDegreeOfCentralizationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Degrees of Centralization. + """ + model = Polity_degree_of_centralization + pagination_class = SeshatAPIPagination + + +class PolitySuprapolityRelationsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Suprapolity Relations. + """ + model = Polity_suprapolity_relations + pagination_class = SeshatAPIPagination + + +class PolityUTMZoneViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity UTM Zones. + """ + model = Polity_utm_zone + pagination_class = SeshatAPIPagination + + +class PolityCapitalViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Capitals. + """ + model = Polity_capital + pagination_class = SeshatAPIPagination + + +class PolityLanguageViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Languages. + """ + model = Polity_language + pagination_class = SeshatAPIPagination + + +class PolityLinguisticFamilyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Linguistic Families. + """ + model = Polity_linguistic_family + pagination_class = SeshatAPIPagination + + +class PolityLanguageGenusViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Language Genuses. + """ + model = Polity_language_genus + pagination_class = SeshatAPIPagination + + +class PolityReligionGenusViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Religion Genuses. + """ + model = Polity_religion_genus + pagination_class = SeshatAPIPagination + + +class PolityReligionFamilyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Religion Families. + """ + model = Polity_religion_family + pagination_class = SeshatAPIPagination + + +class PolityReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Religions. + """ + model = Polity_religion + pagination_class = SeshatAPIPagination + + +class PolityRelationshipToPrecedingEntityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Relationships to Preceding Entities. + """ + model = Polity_relationship_to_preceding_entity + pagination_class = SeshatAPIPagination + + +class PolityPrecedingEntityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Preceding Entities. + """ + model = Polity_preceding_entity + pagination_class = SeshatAPIPagination + + +class PolitySucceedingEntityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Succeeding Entities. + """ + model = Polity_succeeding_entity + pagination_class = SeshatAPIPagination + + +class PolitySupraculturalEntityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Supracultural Entities. + """ + model = Polity_supracultural_entity + pagination_class = SeshatAPIPagination + + +class PolityScaleOfSupraculturalInteractionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Scales of Supracultural Interaction. + """ + model = Polity_scale_of_supracultural_interaction + pagination_class = SeshatAPIPagination + + +class PolityAlternateReligionGenusViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Alternate Religion Genuses. + """ + model = Polity_alternate_religion_genus + pagination_class = SeshatAPIPagination + + +class PolityAlternateReligionFamilyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Alternate Religion Families. + """ + model = Polity_alternate_religion_family + pagination_class = SeshatAPIPagination + + +class PolityAlternateReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Alternate Religions. + """ + model = Polity_alternate_religion + pagination_class = SeshatAPIPagination + + +class PolityExpertViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Experts. + """ + model = Polity_expert + pagination_class = SeshatAPIPagination + + +class PolityEditorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Editors. + """ + model = Polity_editor + pagination_class = SeshatAPIPagination + + +class PolityReligiousTraditionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Religious Traditions. + """ + model = Polity_religious_tradition + pagination_class = SeshatAPIPagination diff --git a/seshat/apps/seshat_api/views/rt.py b/seshat/apps/seshat_api/views/rt.py new file mode 100644 index 000000000..cfdef6c76 --- /dev/null +++ b/seshat/apps/seshat_api/views/rt.py @@ -0,0 +1,241 @@ +from rest_framework import viewsets + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + +from ...rt.models import ( + Widespread_religion, + Official_religion, + Elites_religion, + Theo_sync_dif_rel, + Sync_rel_pra_ind_beli, + Religious_fragmentation, + Gov_vio_freq_rel_grp, + Gov_res_pub_wor, + Gov_res_pub_pros, + Gov_res_conv, + Gov_press_conv, + Gov_res_prop_own_for_rel_grp, + Tax_rel_adh_act_ins, + Gov_obl_rel_grp_ofc_reco, + Gov_res_cons_rel_buil, + Gov_res_rel_edu, + Gov_res_cir_rel_lit, + Gov_dis_rel_grp_occ_fun, + Soc_vio_freq_rel_grp, + Soc_dis_rel_grp_occ_fun, + Gov_press_conv_for_aga, +) + + +class WidespreadReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Widespread Religions. + """ + model = Widespread_religion + pagination_class = SeshatAPIPagination + + +class OfficialReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Official Religions. + """ + model = Official_religion + pagination_class = SeshatAPIPagination + + +class ElitesReligionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Elites Religions. + """ + model = Elites_religion + pagination_class = SeshatAPIPagination + + +class TheoSyncDifRelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Theo Sync Dif Rels. + """ + model = Theo_sync_dif_rel + pagination_class = SeshatAPIPagination + + +class SyncRelPraIndBeliViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Sync Rel Pra Ind Belis. + """ + model = Sync_rel_pra_ind_beli + pagination_class = SeshatAPIPagination + + +class ReligiousFragmentationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Religious Fragmentations. + """ + model = Religious_fragmentation + pagination_class = SeshatAPIPagination + + +class GovVioFreqRelGrpViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Vio Freq Rel Grps. + """ + model = Gov_vio_freq_rel_grp + pagination_class = SeshatAPIPagination + + +class GovResPubWorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Pub Wors. + """ + model = Gov_res_pub_wor + pagination_class = SeshatAPIPagination + + +class GovResPubProsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Pub Proses. + """ + model = Gov_res_pub_pros + pagination_class = SeshatAPIPagination + + +class GovResConvViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Convs. + """ + model = Gov_res_conv + pagination_class = SeshatAPIPagination + + +class GovPressConvViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Press Convs. + """ + model = Gov_press_conv + pagination_class = SeshatAPIPagination + + +class GovResPropOwnForRelGrpViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Prop Own For Rel Grps. + """ + model = Gov_res_prop_own_for_rel_grp + pagination_class = SeshatAPIPagination + + +class TaxRelAdhActInsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Tax Rel Adh Act Inses. + """ + model = Tax_rel_adh_act_ins + pagination_class = SeshatAPIPagination + + +class GovOblRelGrpOfcRecoViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Obl Rel Grp Ofc Recos. + """ + model = Gov_obl_rel_grp_ofc_reco + pagination_class = SeshatAPIPagination + + +class GovResConsRelBuilViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Cons Rel Buils. + """ + model = Gov_res_cons_rel_buil + pagination_class = SeshatAPIPagination + + +class GovResRelEduViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Rel Edus. + """ + model = Gov_res_rel_edu + pagination_class = SeshatAPIPagination + + +class GovResCirRelLitViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Res Cir Rel Lits. + """ + model = Gov_res_cir_rel_lit + pagination_class = SeshatAPIPagination + + +class GovDisRelGrpOccFunViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Dis Rel Grp Occ Funs. + """ + model = Gov_dis_rel_grp_occ_fun + pagination_class = SeshatAPIPagination + + +class SocVioFreqRelGrpViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Soc Vio Freq Rel Grps. + """ + model = Soc_vio_freq_rel_grp + pagination_class = SeshatAPIPagination + + +class SocDisRelGrpOccFunViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Soc Dis Rel Grp Occ Funs. + """ + model = Soc_dis_rel_grp_occ_fun + pagination_class = SeshatAPIPagination + + +class GovPressConvForAgaViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gov Press Conv For Agas. + """ + model = Gov_press_conv_for_aga + pagination_class = SeshatAPIPagination diff --git a/seshat/apps/seshat_api/views/sc.py b/seshat/apps/seshat_api/views/sc.py new file mode 100644 index 000000000..ca2a864f0 --- /dev/null +++ b/seshat/apps/seshat_api/views/sc.py @@ -0,0 +1,873 @@ +from rest_framework import viewsets + +from rest_framework.generics import ( + ListCreateAPIView, + RetrieveUpdateDestroyAPIView, +) + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + +from ...sc.models import ( + Ra, + Polity_territory, + Polity_population, + Population_of_the_largest_settlement, + Settlement_hierarchy, + Administrative_level, + Religious_level, + Military_level, + Professional_military_officer, + Professional_soldier, + Professional_priesthood, + Full_time_bureaucrat, + Examination_system, + Merit_promotion, + Specialized_government_building, + Formal_legal_code, + Judge, + Court, + Professional_lawyer, + Irrigation_system, + Drinking_water_supply_system, + Market, + Food_storage_site, + Road, + Bridge, + Canal, + Port, + Mines_or_quarry, + Mnemonic_device, + Nonwritten_record, + Written_record, + Script, + Non_phonetic_writing, + Phonetic_alphabetic_writing, + Lists_tables_and_classification, + Calendar, + Sacred_text, + Religious_literature, + Practical_literature, + History, + Philosophy, + Scientific_literature, + Fiction, + Article, + Token, + Precious_metal, + Foreign_coin, + Indigenous_coin, + Paper_currency, + Courier, + Postal_station, + General_postal_service, + Communal_building, + Utilitarian_public_building, + Symbolic_building, + Entertainment_building, + Knowledge_or_information_building, + Other_utilitarian_public_building, + Special_purpose_site, + Ceremonial_site, + Burial_site, + Trading_emporia, + Enclosure, + Length_measurement_system, + Area_measurement_system, + Volume_measurement_system, + Weight_measurement_system, + Time_measurement_system, + Geometrical_measurement_system, + Other_measurement_system, + Debt_and_credit_structure, + Store_of_wealth, + Source_of_support, + Occupational_complexity, + Special_purpose_house, + Other_special_purpose_site, + Largest_communication_distance, + Fastest_individual_communication, +) + + +class RAViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing RAs. + """ + model = Ra + pagination_class = SeshatAPIPagination + + +class PolityTerritoryViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Territories. + """ + model = Polity_territory + pagination_class = SeshatAPIPagination + + +class PolityPopulationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polity Populations. + """ + model = Polity_population + pagination_class = SeshatAPIPagination + + +class PopulationOfTheLargestSettlementViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Population of the Largest Settlements. + """ + model = Population_of_the_largest_settlement + pagination_class = SeshatAPIPagination + + +class SettlementHierarchyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Settlement Hierarchies. + """ + model = Settlement_hierarchy + pagination_class = SeshatAPIPagination + + +class AdministrativeLevelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Administrative Levels. + """ + model = Administrative_level + pagination_class = SeshatAPIPagination + + +class ReligiousLevelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Religious Levels. + """ + model = Religious_level + pagination_class = SeshatAPIPagination + + +class MilitaryLevelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Military Levels. + """ + model = Military_level + pagination_class = SeshatAPIPagination + + +class ProfessionalMilitaryOfficerViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Professional Military Officers. + """ + model = Professional_military_officer + pagination_class = SeshatAPIPagination + + +class ProfessionalSoldierViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Professional Soldiers. + """ + model = Professional_soldier + pagination_class = SeshatAPIPagination + + +class ProfessionalPriesthoodViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Professional Priesthoods. + """ + model = Professional_priesthood + pagination_class = SeshatAPIPagination + + +class FullTimeBureaucratViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Full Time Bureaucrats. + """ + model = Full_time_bureaucrat + pagination_class = SeshatAPIPagination + + +class ExaminationSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Examination Systems. + """ + model = Examination_system + pagination_class = SeshatAPIPagination + + +class MeritPromotionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Merit Promotions. + """ + model = Merit_promotion + pagination_class = SeshatAPIPagination + + +class SpecializedGovernmentBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Specialized Government Buildings. + """ + model = Specialized_government_building + pagination_class = SeshatAPIPagination + + +class FormalLegalCodeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Formal Legal Codes. + """ + model = Formal_legal_code + pagination_class = SeshatAPIPagination + + +class JudgeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Judges. + """ + model = Judge + pagination_class = SeshatAPIPagination + + +class CourtViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Courts. + """ + model = Court + pagination_class = SeshatAPIPagination + + +class ProfessionalLawyerViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Professional Lawyers. + """ + model = Professional_lawyer + pagination_class = SeshatAPIPagination + + +class IrrigationSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Irrigation Systems. + """ + model = Irrigation_system + pagination_class = SeshatAPIPagination + + +class DrinkingWaterSupplySystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Drinking Water Supply Systems. + """ + model = Drinking_water_supply_system + pagination_class = SeshatAPIPagination + + +class MarketViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Markets. + """ + model = Market + pagination_class = SeshatAPIPagination + + +class FoodStorageSiteViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Food Storage Sites. + """ + model = Food_storage_site + pagination_class = SeshatAPIPagination + + +class RoadViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Roads. + """ + model = Road + pagination_class = SeshatAPIPagination + + +class BridgeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Bridges. + """ + model = Bridge + pagination_class = SeshatAPIPagination + + +class CanalViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Canals. + """ + model = Canal + pagination_class = SeshatAPIPagination + + +class PortViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Ports. + """ + model = Port + pagination_class = SeshatAPIPagination + + +class MinesOrQuarryViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Mines or Quarries. + """ + model = Mines_or_quarry + pagination_class = SeshatAPIPagination + + +class MnemonicDeviceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Mnemonic Devices. + """ + model = Mnemonic_device + pagination_class = SeshatAPIPagination + + +class NonwrittenRecordViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Nonwritten Records. + """ + model = Nonwritten_record + pagination_class = SeshatAPIPagination + + +class WrittenRecordViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Written Records. + """ + model = Written_record + pagination_class = SeshatAPIPagination + + +class ScriptViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Scripts. + """ + model = Script + pagination_class = SeshatAPIPagination + + +class NonPhoneticWritingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Non-Phonetic Writings. + """ + model = Non_phonetic_writing + pagination_class = SeshatAPIPagination + + +class PhoneticAlphabeticWritingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Phonetic Alphabetic Writings. + """ + model = Phonetic_alphabetic_writing + pagination_class = SeshatAPIPagination + + +class ListsTablesAndClassificationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Lists, Tables, and Classifications. + """ + model = Lists_tables_and_classification + pagination_class = SeshatAPIPagination + + +class CalendarViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Calendars. + """ + model = Calendar + pagination_class = SeshatAPIPagination + + +class SacredTextViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Sacred Texts. + """ + model = Sacred_text + pagination_class = SeshatAPIPagination + + +class ReligiousLiteratureViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Religious Literatures. + """ + model = Religious_literature + pagination_class = SeshatAPIPagination + + +class PracticalLiteratureViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Practical Literatures. + """ + model = Practical_literature + pagination_class = SeshatAPIPagination + + +class HistoryViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Histories. + """ + model = History + pagination_class = SeshatAPIPagination + + +class PhilosophyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Philosophies. + """ + model = Philosophy + pagination_class = SeshatAPIPagination + + +class ScientificLiteratureViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Scientific Literatures. + """ + model = Scientific_literature + pagination_class = SeshatAPIPagination + + +class FictionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Fictions. + """ + model = Fiction + pagination_class = SeshatAPIPagination + + +class ArticleViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Articles. + """ + model = Article + pagination_class = SeshatAPIPagination + + +class TokenViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Tokens. + """ + model = Token + pagination_class = SeshatAPIPagination + + +class PreciousMetalViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Precious Metals. + """ + model = Precious_metal + pagination_class = SeshatAPIPagination + + +class ForeignCoinViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Foreign Coins. + """ + model = Foreign_coin + pagination_class = SeshatAPIPagination + + +class IndigenousCoinViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Indigenous Coins. + """ + model = Indigenous_coin + pagination_class = SeshatAPIPagination + + +class PaperCurrencyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Paper Currencies. + """ + model = Paper_currency + pagination_class = SeshatAPIPagination + + +class CourierViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Couriers. + """ + model = Courier + pagination_class = SeshatAPIPagination + + +class PostalStationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Postal Stations. + """ + model = Postal_station + pagination_class = SeshatAPIPagination + + +class GeneralPostalServiceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing General Postal Services. + """ + model = General_postal_service + pagination_class = SeshatAPIPagination + + +class CommunalBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Communal Buildings. + """ + model = Communal_building + pagination_class = SeshatAPIPagination + + +class UtilitarianPublicBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Utilitarian Public Buildings. + """ + model = Utilitarian_public_building + pagination_class = SeshatAPIPagination + + +class SymbolicBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Symbolic Buildings. + """ + model = Symbolic_building + pagination_class = SeshatAPIPagination + + +class EntertainmentBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Entertainment Buildings. + """ + model = Entertainment_building + pagination_class = SeshatAPIPagination + + +class KnowledgeOrInformationBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Knowledge or Information Buildings. + """ + model = Knowledge_or_information_building + pagination_class = SeshatAPIPagination + + +class OtherUtilitarianPublicBuildingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Other Utilitarian Public Buildings. + """ + model = Other_utilitarian_public_building + pagination_class = SeshatAPIPagination + + +class SpecialPurposeSiteViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Special Purpose Sites. + """ + model = Special_purpose_site + pagination_class = SeshatAPIPagination + + +class CeremonialSiteViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Ceremonial Sites. + """ + model = Ceremonial_site + pagination_class = SeshatAPIPagination + + +class BurialSiteViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Burial Sites. + """ + model = Burial_site + pagination_class = SeshatAPIPagination + + +class TradingEmporiaViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Trading Emporias. + """ + model = Trading_emporia + pagination_class = SeshatAPIPagination + + +class EnclosureViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Enclosures. + """ + model = Enclosure + pagination_class = SeshatAPIPagination + + +class LengthMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Length Measurement Systems. + """ + model = Length_measurement_system + pagination_class = SeshatAPIPagination + + +class AreaMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Area Measurement Systems. + """ + model = Area_measurement_system + pagination_class = SeshatAPIPagination + + +class VolumeMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Volume Measurement Systems. + """ + model = Volume_measurement_system + pagination_class = SeshatAPIPagination + + +class WeightMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Weight Measurement Systems. + """ + model = Weight_measurement_system + pagination_class = SeshatAPIPagination + + +class TimeMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Time Measurement Systems. + """ + model = Time_measurement_system + pagination_class = SeshatAPIPagination + + +class GeometricalMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Geometrical Measurement Systems. + """ + model = Geometrical_measurement_system + pagination_class = SeshatAPIPagination + + +class OtherMeasurementSystemViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Other Measurement Systems. + """ + model = Other_measurement_system + pagination_class = SeshatAPIPagination + + +class DebtAndCreditStructureViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Debt and Credit Structures. + """ + model = Debt_and_credit_structure + pagination_class = SeshatAPIPagination + + +class StoreOfWealthViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Stores of Wealth. + """ + model = Store_of_wealth + pagination_class = SeshatAPIPagination + + +class SourceOfSupportViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Sources of Support. + """ + model = Source_of_support + pagination_class = SeshatAPIPagination + + +class OccupationalComplexityViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Occupational Complexities. + """ + model = Occupational_complexity + pagination_class = SeshatAPIPagination + + +class SpecialPurposeHouseViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Special Purpose Houses. + """ + model = Special_purpose_house + pagination_class = SeshatAPIPagination + + +class OtherSpecialPurposeSiteViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Other Special Purpose Sites. + """ + model = Other_special_purpose_site + pagination_class = SeshatAPIPagination + + +class LargestCommunicationDistanceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Largest Communication Distances. + """ + model = Largest_communication_distance + pagination_class = SeshatAPIPagination + + +class FastestIndividualCommunicationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Fastest Individual Communications. + """ + model = Fastest_individual_communication + pagination_class = SeshatAPIPagination diff --git a/seshat/apps/seshat_api/views/wf.py b/seshat/apps/seshat_api/views/wf.py new file mode 100644 index 000000000..58d273451 --- /dev/null +++ b/seshat/apps/seshat_api/views/wf.py @@ -0,0 +1,555 @@ +from rest_framework import viewsets + +from rest_framework.generics import ( + ListCreateAPIView, + RetrieveUpdateDestroyAPIView, +) + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) + + +from ...wf.models import ( + Long_wall, + Copper, + Bronze, + Iron, + Steel, + Javelin, + Atlatl, + Sling, + Self_bow, + Composite_bow, + Crossbow, + Tension_siege_engine, + Sling_siege_engine, + Gunpowder_siege_artillery, + Handheld_firearm, + War_club, + Battle_axe, + Dagger, + Sword, + Spear, + Polearm, + Dog, + Donkey, + Horse, + Camel, + Elephant, + Wood_bark_etc, + Leather_cloth, + Shield, + Helmet, + Breastplate, + Limb_protection, + Scaled_armor, + Laminar_armor, + Plate_armor, + Small_vessels_canoes_etc, + Merchant_ships_pressed_into_service, + Specialized_military_vessel, + Settlements_in_a_defensive_position, + Wooden_palisade, + Earth_rampart, + Ditch, + Moat, + Stone_walls_non_mortared, + Stone_walls_mortared, + Fortified_camp, + Complex_fortification, + Modern_fortification, + Chainmail, +) + + +class LongWallViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Long Walls. + """ + model = Long_wall + pagination_class = SeshatAPIPagination + + +class CopperViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Coppers. + """ + model = Copper + pagination_class = SeshatAPIPagination + + +class BronzeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Bronzes. + """ + model = Bronze + pagination_class = SeshatAPIPagination + + +class IronViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Irons. + """ + model = Iron + pagination_class = SeshatAPIPagination + + +class SteelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Steels. + """ + model = Steel + pagination_class = SeshatAPIPagination + + +class JavelinViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Javelins. + """ + model = Javelin + pagination_class = SeshatAPIPagination + + +class AtlatlViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Atlatls. + """ + model = Atlatl + pagination_class = SeshatAPIPagination + + +class SlingViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Slings. + """ + model = Sling + pagination_class = SeshatAPIPagination + + +class SelfBowViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Self Bows. + """ + model = Self_bow + pagination_class = SeshatAPIPagination + + +class CompositeBowViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Composite Bows. + """ + model = Composite_bow + pagination_class = SeshatAPIPagination + + +class CrossbowViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Crossbows. + """ + model = Crossbow + pagination_class = SeshatAPIPagination + + +class TensionSiegeEngineViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Tension Siege Engines. + """ + model = Tension_siege_engine + pagination_class = SeshatAPIPagination + + +class SlingSiegeEngineViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Sling Siege Engines. + """ + model = Sling_siege_engine + pagination_class = SeshatAPIPagination + + +class GunpowderSiegeArtilleryViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Gunpowder Siege Artilleries. + """ + model = Gunpowder_siege_artillery + pagination_class = SeshatAPIPagination + + +class HandheldFirearmViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Handheld Firearms. + """ + model = Handheld_firearm + pagination_class = SeshatAPIPagination + + +class WarClubViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing War Clubs. + """ + model = War_club + pagination_class = SeshatAPIPagination + + +class BattleAxeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Battle Axes. + """ + model = Battle_axe + pagination_class = SeshatAPIPagination + + +class DaggerViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Daggers. + """ + model = Dagger + pagination_class = SeshatAPIPagination + + +class SwordViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Swords. + """ + model = Sword + pagination_class = SeshatAPIPagination + + +class SpearViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Spears. + """ + model = Spear + pagination_class = SeshatAPIPagination + + +class PolearmViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Polearms. + """ + model = Polearm + pagination_class = SeshatAPIPagination + + +class DogViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Dogs. + """ + model = Dog + pagination_class = SeshatAPIPagination + + +class DonkeyViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Donkeys. + """ + model = Donkey + pagination_class = SeshatAPIPagination + + +class HorseViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Horses. + """ + model = Horse + pagination_class = SeshatAPIPagination + + +class CamelViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Camels. + """ + model = Camel + pagination_class = SeshatAPIPagination + + +class ElephantViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Elephants. + """ + model = Elephant + pagination_class = SeshatAPIPagination + + +class WoodBarkEtcViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Wood bark, etc. + """ + model = Wood_bark_etc + pagination_class = SeshatAPIPagination + + +class LeatherClothViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Leather Cloth. + """ + model = Leather_cloth + pagination_class = SeshatAPIPagination + + +class ShieldViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Shields. + """ + model = Shield + pagination_class = SeshatAPIPagination + + +class HelmetViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Helmets. + """ + model = Helmet + pagination_class = SeshatAPIPagination + + +class BreastplateViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Breastplates. + """ + model = Breastplate + pagination_class = SeshatAPIPagination + + +class LimbProtectionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Limb Protections. + """ + model = Limb_protection + pagination_class = SeshatAPIPagination + + +class ScaledArmorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Scaled Armors. + """ + model = Scaled_armor + pagination_class = SeshatAPIPagination + + +class LaminarArmorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Laminar Armors. + """ + model = Laminar_armor + pagination_class = SeshatAPIPagination + + +class PlateArmorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Plate Armors. + """ + model = Plate_armor + pagination_class = SeshatAPIPagination + + +class SmallVesselsCanoesEtcViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Small Vessels, Canoes, etc. + """ + model = Small_vessels_canoes_etc + pagination_class = SeshatAPIPagination + + +class MerchantShipPressedIntoServiceViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Merchant Ships Pressed Into Services. + """ + model = Merchant_ships_pressed_into_service + pagination_class = SeshatAPIPagination + + +class SpecializedMilitaryVesselViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Specialized Military Vessels. + """ + model = Specialized_military_vessel + pagination_class = SeshatAPIPagination + + +class SettlementInADefensivePositionViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Settlements in a Defensive Position. + """ + model = Settlements_in_a_defensive_position + pagination_class = SeshatAPIPagination + + +class WoodenPalisadeViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Wooden Palisades. + """ + model = Wooden_palisade + pagination_class = SeshatAPIPagination + + +class EarthRampartViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Earth Ramparts. + """ + model = Earth_rampart + pagination_class = SeshatAPIPagination + + +class DitchViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Ditches. + """ + model = Ditch + pagination_class = SeshatAPIPagination + + +class MoatViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Moats. + """ + model = Moat + pagination_class = SeshatAPIPagination + + +class StoneWallsNonMortaredViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Stone Walls Non Mortared. + """ + model = Stone_walls_non_mortared + pagination_class = SeshatAPIPagination + + +class StoneWallsMortaredViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Stone Walls Mortared. + """ + model = Stone_walls_mortared + pagination_class = SeshatAPIPagination + + +class FortifiedCampViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Fortified Camps. + """ + model = Fortified_camp + pagination_class = SeshatAPIPagination + + +class ComplexFortificationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Complex Fortifications. + """ + model = Complex_fortification + pagination_class = SeshatAPIPagination + + +class ModernFortificationViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Modern Fortifications. + """ + model = Modern_fortification + pagination_class = SeshatAPIPagination + + +class ChainmailViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Chainmails. + """ + model = Chainmail + pagination_class = SeshatAPIPagination From 2b3ff028aa75abd06ba2b0af6d87c21cba30fcf8 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:01:31 +0100 Subject: [PATCH 05/16] Adding in general serializer --- seshat/apps/seshat_api/serializers.py | 164 ++------------------------ 1 file changed, 9 insertions(+), 155 deletions(-) diff --git a/seshat/apps/seshat_api/serializers.py b/seshat/apps/seshat_api/serializers.py index 96e83d765..5d6da7516 100644 --- a/seshat/apps/seshat_api/serializers.py +++ b/seshat/apps/seshat_api/serializers.py @@ -1,161 +1,15 @@ - -################ Beginning of Serializers Imports (TODO: Make them automatic too) - -from django.contrib.auth.models import User, Group from rest_framework import serializers -from seshat.apps.crisisdb.models import Human_sacrifice, External_conflict, Internal_conflict, External_conflict_side, Agricultural_population, Arable_land, Arable_land_per_farmer, Gross_grain_shared_per_agricultural_population, Net_grain_shared_per_agricultural_population, Surplus, Military_expense, Silver_inflow, Silver_stock, Total_population, Gdp_per_capita, Drought_event, Locust_event, Socioeconomic_turmoil_event, Crop_failure_event, Famine_event, Disease_outbreak -from ..core.models import Polity, Reference, Section, Subsection, Variablehierarchy - -################ End of Serializers Imports - -################ Beginning of Base Serializers -class UserSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = User - fields = ['url', 'username', 'email', 'groups'] - -class GroupSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = Group - fields = ['url', 'name'] - -class ReferenceSerializer(serializers.ModelSerializer): - class Meta: - model = Reference - fields = ['id', 'title', 'year', 'creator', 'zotero_link', 'long_name'] - -################ End of Base Serializers -################ Beginning of Serializers Imports - -class Human_sacrificeSerializer(serializers.ModelSerializer): - class Meta: - model = Human_sacrifice - fields = ['year_from', 'year_to', 'human_sacrifice', 'tag'] - -class External_conflictSerializer(serializers.ModelSerializer): - class Meta: - model = External_conflict - fields = ['year_from', 'year_to', 'conflict_name', 'tag'] - -class Internal_conflictSerializer(serializers.ModelSerializer): - class Meta: - model = Internal_conflict - fields = ['year_from', 'year_to', 'conflict', 'expenditure', 'leader', 'casualty', 'tag'] - -class External_conflict_sideSerializer(serializers.ModelSerializer): - class Meta: - model = External_conflict_side - fields = ['year_from', 'year_to', 'conflict_id', 'expenditure', 'leader', 'casualty', 'tag'] - -class Agricultural_populationSerializer(serializers.ModelSerializer): - class Meta: - model = Agricultural_population - fields = ['year_from', 'year_to', 'agricultural_population', 'tag'] - -class Arable_landSerializer(serializers.ModelSerializer): - class Meta: - model = Arable_land - fields = ['year_from', 'year_to', 'arable_land', 'tag'] -class Arable_land_per_farmerSerializer(serializers.ModelSerializer): - class Meta: - model = Arable_land_per_farmer - fields = ['year_from', 'year_to', 'arable_land_per_farmer', 'tag'] -class Gross_grain_shared_per_agricultural_populationSerializer(serializers.ModelSerializer): - class Meta: - model = Gross_grain_shared_per_agricultural_population - fields = ['year_from', 'year_to', 'gross_grain_shared_per_agricultural_population', 'tag'] +SESHAT_API_DEPTH = 3 +"""Defines the depth of recursive serialization across all models.""" -class Net_grain_shared_per_agricultural_populationSerializer(serializers.ModelSerializer): - class Meta: - model = Net_grain_shared_per_agricultural_population - fields = ['year_from', 'year_to', 'net_grain_shared_per_agricultural_population', 'tag'] -class SurplusSerializer(serializers.ModelSerializer): +class GeneralSerializer(serializers.ModelSerializer): + """ + A serializer for all models across the API. + """ class Meta: - model = Surplus - fields = ['year_from', 'year_to', 'surplus', 'tag'] - -class Military_expenseSerializer(serializers.ModelSerializer): - class Meta: - model = Military_expense - fields = ['year_from', 'year_to', 'conflict', 'expenditure', 'tag'] - -class Silver_inflowSerializer(serializers.ModelSerializer): - class Meta: - model = Silver_inflow - fields = ['year_from', 'year_to', 'silver_inflow', 'tag'] - -class Silver_stockSerializer(serializers.ModelSerializer): - class Meta: - model = Silver_stock - fields = ['year_from', 'year_to', 'silver_stock', 'tag'] - -class Total_populationSerializer(serializers.ModelSerializer): - class Meta: - model = Total_population - fields = ['year_from', 'year_to', 'total_population', 'tag'] - -class Gdp_per_capitaSerializer(serializers.ModelSerializer): - class Meta: - model = Gdp_per_capita - fields = ['year_from', 'year_to', 'gdp_per_capita', 'tag'] - -class Drought_eventSerializer(serializers.ModelSerializer): - class Meta: - model = Drought_event - fields = ['year_from', 'year_to', 'drought_event', 'tag'] - -class Locust_eventSerializer(serializers.ModelSerializer): - class Meta: - model = Locust_event - fields = ['year_from', 'year_to', 'locust_event', 'tag'] - -class Socioeconomic_turmoil_eventSerializer(serializers.ModelSerializer): - class Meta: - model = Socioeconomic_turmoil_event - fields = ['year_from', 'year_to', 'socioeconomic_turmoil_event', 'tag'] - -class Crop_failure_eventSerializer(serializers.ModelSerializer): - class Meta: - model = Crop_failure_event - fields = ['year_from', 'year_to', 'crop_failure_event', 'tag'] - -class Famine_eventSerializer(serializers.ModelSerializer): - class Meta: - model = Famine_event - fields = ['year_from', 'year_to', 'famine_event', 'tag'] - -class Disease_outbreakSerializer(serializers.ModelSerializer): - class Meta: - model = Disease_outbreak - fields = ['year_from', 'year_to', 'longitude', 'latitude', 'elevation', 'sub_category', 'magnitude', 'duration', 'tag'] -class PolitySerializer(serializers.ModelSerializer): - crisisdb_human_sacrifice_related = Human_sacrificeSerializer(many=True, read_only=True) - crisisdb_external_conflict_related = External_conflictSerializer(many=True, read_only=True) - crisisdb_internal_conflict_related = Internal_conflictSerializer(many=True, read_only=True) - crisisdb_external_conflict_side_related = External_conflict_sideSerializer(many=True, read_only=True) - crisisdb_agricultural_population_related = Agricultural_populationSerializer(many=True, read_only=True) - crisisdb_arable_land_related = Arable_landSerializer(many=True, read_only=True) - crisisdb_arable_land_per_farmer_related = Arable_land_per_farmerSerializer(many=True, read_only=True) - crisisdb_gross_grain_shared_per_agricultural_population_related = Gross_grain_shared_per_agricultural_populationSerializer(many=True, read_only=True) - crisisdb_net_grain_shared_per_agricultural_population_related = Net_grain_shared_per_agricultural_populationSerializer(many=True, read_only=True) - crisisdb_surplus_related = SurplusSerializer(many=True, read_only=True) - crisisdb_military_expense_related = Military_expenseSerializer(many=True, read_only=True) - crisisdb_silver_inflow_related = Silver_inflowSerializer(many=True, read_only=True) - crisisdb_silver_stock_related = Silver_stockSerializer(many=True, read_only=True) - crisisdb_total_population_related = Total_populationSerializer(many=True, read_only=True) - crisisdb_gdp_per_capita_related = Gdp_per_capitaSerializer(many=True, read_only=True) - crisisdb_drought_event_related = Drought_eventSerializer(many=True, read_only=True) - crisisdb_locust_event_related = Locust_eventSerializer(many=True, read_only=True) - crisisdb_socioeconomic_turmoil_event_related = Socioeconomic_turmoil_eventSerializer(many=True, read_only=True) - crisisdb_crop_failure_event_related = Crop_failure_eventSerializer(many=True, read_only=True) - crisisdb_famine_event_related = Famine_eventSerializer(many=True, read_only=True) - crisisdb_disease_outbreak_related = Disease_outbreakSerializer(many=True, read_only=True) - - class Meta: - model = Polity - fields = ['id', 'name', 'start_year', 'end_year', 'crisisdb_human_sacrifice_related', 'crisisdb_external_conflict_related', 'crisisdb_internal_conflict_related', 'crisisdb_external_conflict_side_related', 'crisisdb_agricultural_population_related', 'crisisdb_arable_land_related', 'crisisdb_arable_land_per_farmer_related', 'crisisdb_gross_grain_shared_per_agricultural_population_related', 'crisisdb_net_grain_shared_per_agricultural_population_related', 'crisisdb_surplus_related', 'crisisdb_military_expense_related', 'crisisdb_silver_inflow_related', 'crisisdb_silver_stock_related', 'crisisdb_total_population_related', 'crisisdb_gdp_per_capita_related', 'crisisdb_drought_event_related', 'crisisdb_locust_event_related', 'crisisdb_socioeconomic_turmoil_event_related', 'crisisdb_crop_failure_event_related', 'crisisdb_famine_event_related', 'crisisdb_disease_outbreak_related'] - -################ End of Serializers Imports + model = None + fields = '__all__' + depth = SESHAT_API_DEPTH From ba2760428377d3d24f05715dfd79a2d78fe99949 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:01:39 +0100 Subject: [PATCH 06/16] Setting up all URL paths for API --- seshat/apps/seshat_api/urls.py | 1097 +++++++++++++++++++++++++++++++- 1 file changed, 1067 insertions(+), 30 deletions(-) diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index 24a901c16..6dd647889 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -1,42 +1,1079 @@ from django.urls import path, include from rest_framework import routers -#from rest_framework.urlpatterns import format_suffix_patterns +from . import views # temp -- remove -from . import views -# from .views import PolityDetail, PolityList # VarList, VarDetail +# Create router for URLS +router = routers.DefaultRouter() -router = routers.DefaultRouter() -router.register(r'users', views.UserViewSet) -router.register(r'groups', views.GroupViewSet) -router.register(r'politys-api', views.PolityViewSet) -#router.register(r'sections', views.SectionViewSet) +# Register viewsets for "account" app +from .views.accounts import ( + ProfileViewSet, + SeshatExpertViewSet, + SeshatTaskViewSet, +) +router.register(r"profiles", ProfileViewSet, basename="profile") +router.register( + r"seshat-experts", + SeshatExpertViewSet, + basename="seshat-expert", +) +router.register(r"seshat-tasks", SeshatTaskViewSet, basename="seshat-task") -#router.register(r'references', views.ReferenceViewSet) +# Register views for "core" app + +from .views.core import ( + PrivateCommentsViewSet, + PrivateCommentsPartsViewSet, + MacroRegionViewSet, + RegionViewSet, + NGAViewSet, + PolityViewSet, + CapitalViewSet, + NGAPolityRelationsViewSet, + CountryViewSet, + SectionViewSet, + SubsectionViewSet, + VariableHierarchyViewSet, + ReferenceViewSet, + CitationViewSet, + SeshatCommentViewSet, + SeshatCommentPartViewSet, + ScpThroughCtnViewSet, + SeshatCommonViewSet, + ReligionViewSet, + VideoShapefileViewSet, + GADMShapefileViewSet, + GADMCountriesViewSet, + GADMProvincesViewSet, +) + +router.register( + r"private-comments", + PrivateCommentsViewSet, + basename="private-comment", +) +router.register( + r"private-comments-parts", + PrivateCommentsPartsViewSet, + basename="private-comment-part", +) +router.register(r"macro-regions", MacroRegionViewSet, basename="macro-region") +router.register(r"regions", RegionViewSet, basename="region") +router.register(r"ngas", NGAViewSet, basename="nga") +router.register(r"polities", PolityViewSet, basename="polity") +router.register(r"capitals", CapitalViewSet, basename="capital") +router.register( + r"nga-polity-relations", + NGAPolityRelationsViewSet, + basename="nga-polity-relation", +) +router.register(r"countries", CountryViewSet, basename="country") +router.register(r"sections", SectionViewSet, basename="section") +router.register(r"subsections", SubsectionViewSet, basename="subsection") +router.register( + r"variable-hierarchies", + VariableHierarchyViewSet, + basename="variable-hierarchy", +) +router.register(r"references", ReferenceViewSet, basename="reference") +router.register(r"citations", CitationViewSet, basename="citation") +router.register(r"comments", SeshatCommentViewSet, basename="seshat-comment") +router.register( + r"comment-parts", + SeshatCommentPartViewSet, + basename="seshat-comment-part", +) +router.register( + r"comment-parts-through-citations", + ScpThroughCtnViewSet, + basename="comment-part-through-citation", +) +router.register(r"commons", SeshatCommonViewSet, basename="common") +router.register(r"religions", ReligionViewSet, basename="religion") +router.register( + r"video-shapefiles", + VideoShapefileViewSet, + basename="video-shapefile", +) +router.register( + r"gadm-shapefiles", + GADMShapefileViewSet, + basename="gadm-shapefile", +) +router.register( + r"gadm-countries", GADMCountriesViewSet, basename="gadm-country" +) +router.register( + r"gadm-provinces", + GADMProvincesViewSet, + basename="gadm-province", +) + + +# Register views for "crisisdb" app + +from .views.crisisdb import ( + USLocationViewSet, + USViolenceSubtypeViewSet, + USViolenceDataSourceViewSet, + USViolenceViewSet, + CrisisConsequenceViewSet, + PowerTransitionViewSet, + HumanSacrificeViewSet, + ExternalConflictViewSet, + ExternalConflictSideViewSet, + AgriculturalPopulationViewSet, + ArableLandViewSet, + ArableLandPerFarmerViewSet, + GrossGrainSharedPerAgriculturalPopulationViewSet, + NetGrainSharedPerAgriculturalPopulationViewSet, + SurplusViewSet, + MilitaryExpenseViewSet, + SilverInflowViewSet, + SilverStockViewSet, + TotalPopulationViewSet, + GDPPerCapitaViewSet, + DroughtEventViewSet, + LocustEventViewSet, + SocioeconomicTurmoilEventViewSet, + CropFailureEventViewSet, + FamineEventViewSet, + DiseaseOutbreakViewSet, +) + +router.register(r"us-locations", USLocationViewSet, basename="us-location") +router.register( + r"us-violence-subtypes", + USViolenceSubtypeViewSet, + basename="us-violence-subtype", +) +router.register( + r"us-violence-data-sources", + USViolenceDataSourceViewSet, + basename="us-violence-data-source", +) +router.register(r"us-violences", USViolenceViewSet, basename="us-violence") +router.register( + r"crisis-consequences", + CrisisConsequenceViewSet, + basename="crisis-consequence", +) +router.register( + r"power-transitions", + PowerTransitionViewSet, + basename="power-transition", +) + +router.register( + r"human-sacrifices", + HumanSacrificeViewSet, + basename="human-sacrifice", +) +router.register( + r"external-conflicts", + ExternalConflictViewSet, + basename="external-conflict", +) +router.register( + r"external-conflict-sides", + ExternalConflictSideViewSet, + basename="external-conflict-side", +) +router.register( + r"agricultural-populations", + AgriculturalPopulationViewSet, + basename="agricultural-population", +) +router.register(r"arable-lands", ArableLandViewSet, basename="arable-land") +router.register( + r"arable-land-per-farmer", + ArableLandPerFarmerViewSet, + basename="arable-land-per-farmer", +) +router.register( + r"gross-grain-shared-per-agricultural-populations", + GrossGrainSharedPerAgriculturalPopulationViewSet, + basename="gross-grain-shared-per-agricultural-population", +) +router.register( + r"net-grain-shared-per-agricultural-populations", + NetGrainSharedPerAgriculturalPopulationViewSet, + basename="net-grain-shared-per-agricultural-population", +) +router.register(r"surpluses", SurplusViewSet, basename="surplus") +router.register( + r"military-expenses", + MilitaryExpenseViewSet, + basename="military-expense", +) +router.register( + r"silver-inflows", + SilverInflowViewSet, + basename="silver-inflow", +) +router.register( + r"silver-stocks", + SilverStockViewSet, + basename="silver-stock", +) +router.register( + r"total-populations", + TotalPopulationViewSet, + basename="total-population", +) +router.register( + r"gdp-per-capitas", + GDPPerCapitaViewSet, + basename="gdp-per-capita", +) +router.register( + r"drought-events", + DroughtEventViewSet, + basename="drought-event", +) +router.register( + r"locust-events", + LocustEventViewSet, + basename="locust-event", +) +router.register( + r"socioeconomic-turmoil-events", + SocioeconomicTurmoilEventViewSet, + basename="socioeconomic-turmoil-event", +) +router.register( + r"crop-failure-events", + CropFailureEventViewSet, + basename="crop-failure-event", +) +router.register( + r"famine-events", + FamineEventViewSet, + basename="famine-event", +) +router.register( + r"disease-outbreaks", + DiseaseOutbreakViewSet, + basename="disease-outbreak", +) + + +# app: general + +from .views.general import ( + PolityResearchAssistantViewSet, + PolityOriginalNameViewSet, + PolityAlternativeNameViewSet, + PolityDurationViewSet, + PolityPeakYearsViewSet, + PolityDegreeOfCentralizationViewSet, + PolitySuprapolityRelationsViewSet, + PolityUTMZoneViewSet, + PolityCapitalViewSet, + PolityLanguageViewSet, + PolityLinguisticFamilyViewSet, + PolityLanguageGenusViewSet, + PolityReligionGenusViewSet, + PolityReligionFamilyViewSet, + PolityReligionViewSet, + PolityRelationshipToPrecedingEntityViewSet, + PolityPrecedingEntityViewSet, + PolitySucceedingEntityViewSet, + PolitySupraculturalEntityViewSet, + PolityScaleOfSupraculturalInteractionViewSet, + PolityAlternateReligionGenusViewSet, + PolityAlternateReligionFamilyViewSet, + PolityAlternateReligionViewSet, + PolityExpertViewSet, + PolityEditorViewSet, + PolityReligiousTraditionViewSet, +) + +router.register( + r"polity-research-assistants", + PolityResearchAssistantViewSet, + basename="polity-research-assistant", +) +router.register( + r"polity-original-names", + PolityOriginalNameViewSet, + basename="polity-original-name", +) +router.register( + r"polity-alternative-names", + PolityAlternativeNameViewSet, + basename="polity-alternative-name", +) +router.register( + r"polity-durations", PolityDurationViewSet, basename="polity-duration" +) +router.register( + r"polity-peak-years", PolityPeakYearsViewSet, basename="polity-peak-years" +) +router.register( + r"polity-degree-of-centralizations", + PolityDegreeOfCentralizationViewSet, + basename="polity-degree-of-centralization", +) +router.register( + r"polity-suprapolities", + PolitySuprapolityRelationsViewSet, + basename="polity-suprapolity", +) +router.register( + r"polity-utm-timezones", + PolityUTMZoneViewSet, + basename="polity-utm-timezone", +) +router.register( + r"polity-capitals", PolityCapitalViewSet, basename="polity-capital" +) +router.register( + r"polity-languages", PolityLanguageViewSet, basename="polity-language" +) +router.register( + r"polity-linguistic-families", + PolityLinguisticFamilyViewSet, + basename="polity-linguistic-family", +) +router.register( + r"polity-language-genuses", + PolityLanguageGenusViewSet, + basename="polity-language-genus", +) +router.register( + r"polity-religion-genuses", + PolityReligionGenusViewSet, + basename="polity-religion-genus", +) +router.register( + r"polity-religion-families", + PolityReligionFamilyViewSet, + basename="polity-religion-family", +) +router.register( + r"polity-religions", PolityReligionViewSet, basename="polity-religion" +) +router.register( + r"polity-relationship-to-preceding-entities", + PolityRelationshipToPrecedingEntityViewSet, + basename="polity-relationship-to-preceding-entity", +) +router.register( + r"polity-preceding-entities", + PolityPrecedingEntityViewSet, + basename="polity-preceding-entity", +) +router.register( + r"polity-succeeding-entities", + PolitySucceedingEntityViewSet, + basename="polity-succeeding-entity", +) +router.register( + r"polity-supracultural-entities", + PolitySupraculturalEntityViewSet, + basename="polity-supracultural-entity", +) +router.register( + r"polity-scale-of-supracultural-interactions", + PolityScaleOfSupraculturalInteractionViewSet, + basename="polity-scale-of-supracultural-interaction", +) +router.register( + r"polity-alternate-religion-genuses", + PolityAlternateReligionGenusViewSet, + basename="polity-alternate-religion-genus", +) +router.register( + r"polity-alternate-religion-families", + PolityAlternateReligionFamilyViewSet, + basename="polity-alternate-religion-family", +) +router.register( + r"polity-alternate-religions", + PolityAlternateReligionViewSet, + basename="polity-alternate-religion", +) +router.register( + r"polity-experts", PolityExpertViewSet, basename="polity-expert" +) +router.register( + r"polity-editors", PolityEditorViewSet, basename="polity-editor" +) +router.register( + r"polity-religious-traditions", + PolityReligiousTraditionViewSet, + basename="polity-religious-tradition", +) -urlpatterns = [ - path('', include(router.urls)), - path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) -] -urlpatterns += [ - path('refs/', views.reference_list), - path('refs//', views.reference_detail), - path('albums/', views.album_list), - path('albums//', views.album_detail), +# Register views for "rt" app + +from .views.rt import ( + WidespreadReligionViewSet, + OfficialReligionViewSet, + ElitesReligionViewSet, + TheoSyncDifRelViewSet, + SyncRelPraIndBeliViewSet, + ReligiousFragmentationViewSet, + GovVioFreqRelGrpViewSet, + GovResPubWorViewSet, + GovResPubProsViewSet, + GovResConvViewSet, + GovPressConvViewSet, + GovResPropOwnForRelGrpViewSet, + TaxRelAdhActInsViewSet, + GovOblRelGrpOfcRecoViewSet, + GovResConsRelBuilViewSet, + GovResRelEduViewSet, + GovResCirRelLitViewSet, + GovDisRelGrpOccFunViewSet, + SocVioFreqRelGrpViewSet, + SocDisRelGrpOccFunViewSet, + GovPressConvForAgaViewSet, +) + +router.register( + r"widespread-religions", + WidespreadReligionViewSet, + basename="widespread-religion", +) +router.register( + r"official-religions", + OfficialReligionViewSet, + basename="official-religion", +) +router.register( + r"elites-religions", ElitesReligionViewSet, basename="elites-religion" +) +router.register( + r"theological-syncretism-of-different-religions", + TheoSyncDifRelViewSet, + basename="theological-syncretism-of-different-religions", +) +router.register( + r"syncretism-of-religious-practices-at-the-level-of-individual-believers", + SyncRelPraIndBeliViewSet, + basename="syncretism-of-religious-practices-at-the-level-of-individual-believers", +) +router.register( + r"religious-fragmentations", + ReligiousFragmentationViewSet, + basename="religious-fragmentation", +) +router.register( + r"frequency-of-governmental-violence-against-religious-groups", + GovVioFreqRelGrpViewSet, + basename="frequency-of-governmental-violence-against-religious-groups", +) +router.register( + r"government-restrictions-on-public-worships", + GovResPubWorViewSet, + basename="government-restrictions-on-public-worships", +) +router.register( + r"government-restrictions-on-public-proselytizings", + GovResPubProsViewSet, + basename="government-restrictions-on-public-proselytizings", +) +router.register( + r"government-restrictions-on-conversions", + GovResConvViewSet, + basename="government-restrictions-on-conversions", +) +router.register( + r"government-pressure-to-converts", + GovPressConvViewSet, + basename="government-pressure-to-converts", +) +router.register( + r"government-restrictions-on-property-ownership-for-adherents-of-and-religious-groups", + GovResPropOwnForRelGrpViewSet, + basename="government-restrictions-on-property-ownership-for-adherents-of-and-religious-groups", +) +router.register( + r"taxes-based-on-religious-adherence-or-on-religious-activities-and-institutions", + TaxRelAdhActInsViewSet, + basename="taxes-based-on-religious-adherence-or-on-religious-activities-and-institutions", +) +router.register( + r"governmental-obligations-for-religious-groups-to-apply-for-official-recognitions", + GovOblRelGrpOfcRecoViewSet, + basename="governmental-obligations-for-religious-groups-to-apply-for-official-recognitions", +) +router.register( + r"government-restrictions-on-construction-of-religious-buildings", + GovResConsRelBuilViewSet, + basename="government-restrictions-on-construction-of-religious-buildings", +) +router.register( + r"government-restrictions-on-religious-educations", + GovResRelEduViewSet, + basename="government-restrictions-on-religious-educations", +) +router.register( + r"government-restrictions-on-circulation-of-religious-literatures", + GovResCirRelLitViewSet, + basename="government-restrictions-on-circulation-of-religious-literatures", +) +router.register( + r"government-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", + GovDisRelGrpOccFunViewSet, + basename="government-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", +) +router.register( + r"frequency-of-societal-violence-against-religious-groups", + SocVioFreqRelGrpViewSet, + basename="frequency-of-societal-violence-against-religious-groups", +) +router.register( + r"societal-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", + SocDisRelGrpOccFunViewSet, + basename="societal-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", +) +router.register( + r"societal-pressure-to-convert-or-against-conversions", + GovPressConvForAgaViewSet, + basename="societal-pressure-to-convert-or-against-conversions", +) + +# Add views for "sc" app to the router + +from .views.sc import ( + RAViewSet, + PolityTerritoryViewSet, + PolityPopulationViewSet, + PopulationOfTheLargestSettlementViewSet, + SettlementHierarchyViewSet, + AdministrativeLevelViewSet, + ReligiousLevelViewSet, + MilitaryLevelViewSet, + ProfessionalMilitaryOfficerViewSet, + ProfessionalSoldierViewSet, + ProfessionalPriesthoodViewSet, + FullTimeBureaucratViewSet, + ExaminationSystemViewSet, + MeritPromotionViewSet, + SpecializedGovernmentBuildingViewSet, + FormalLegalCodeViewSet, + JudgeViewSet, + CourtViewSet, + ProfessionalLawyerViewSet, + IrrigationSystemViewSet, + DrinkingWaterSupplySystemViewSet, + MarketViewSet, + FoodStorageSiteViewSet, + RoadViewSet, + BridgeViewSet, + CanalViewSet, + PortViewSet, + MinesOrQuarryViewSet, + MnemonicDeviceViewSet, + NonwrittenRecordViewSet, + WrittenRecordViewSet, + ScriptViewSet, + NonPhoneticWritingViewSet, + PhoneticAlphabeticWritingViewSet, + ListsTablesAndClassificationViewSet, + CalendarViewSet, + SacredTextViewSet, + ReligiousLiteratureViewSet, + PracticalLiteratureViewSet, + HistoryViewSet, + PhilosophyViewSet, + ScientificLiteratureViewSet, + FictionViewSet, + ArticleViewSet, + TokenViewSet, + PreciousMetalViewSet, + ForeignCoinViewSet, + IndigenousCoinViewSet, + PaperCurrencyViewSet, + CourierViewSet, + PostalStationViewSet, + GeneralPostalServiceViewSet, + CommunalBuildingViewSet, + UtilitarianPublicBuildingViewSet, + SymbolicBuildingViewSet, + EntertainmentBuildingViewSet, + KnowledgeOrInformationBuildingViewSet, + OtherUtilitarianPublicBuildingViewSet, + SpecialPurposeSiteViewSet, + CeremonialSiteViewSet, + BurialSiteViewSet, + TradingEmporiaViewSet, + EnclosureViewSet, + LengthMeasurementSystemViewSet, + AreaMeasurementSystemViewSet, + VolumeMeasurementSystemViewSet, + WeightMeasurementSystemViewSet, + TimeMeasurementSystemViewSet, + GeometricalMeasurementSystemViewSet, + OtherMeasurementSystemViewSet, + DebtAndCreditStructureViewSet, + StoreOfWealthViewSet, + SourceOfSupportViewSet, + OccupationalComplexityViewSet, + SpecialPurposeHouseViewSet, + OtherSpecialPurposeSiteViewSet, + LargestCommunicationDistanceViewSet, + FastestIndividualCommunicationViewSet, +) + +# Register views for "sc" app + +router.register( + r"research-assistants", RAViewSet, basename="research-assistant" +) +router.register( + r"polity-territories", PolityTerritoryViewSet, basename="polity-territory" +) +router.register( + r"polity-populations", + PolityPopulationViewSet, + basename="polity-population", +) +router.register( + r"population-of-the-largest-settlements", + PopulationOfTheLargestSettlementViewSet, + basename="population-of-the-largest-settlement", +) +router.register( + r"settlement-hierarchies", + SettlementHierarchyViewSet, + basename="settlement-hierarchy", +) +router.register( + r"administrative-levels", + AdministrativeLevelViewSet, + basename="administrative-level", +) +router.register( + r"religious-levels", ReligiousLevelViewSet, basename="religious-level" +) +router.register( + r"military-levels", MilitaryLevelViewSet, basename="military-level" +) +router.register( + r"professional-military-officers", + ProfessionalMilitaryOfficerViewSet, + basename="professional-military-officer", +) +router.register( + r"professional-soldiers", + ProfessionalSoldierViewSet, + basename="professional-soldier", +) +router.register( + r"professional-priesthoods", + ProfessionalPriesthoodViewSet, + basename="professional-priesthood", +) +router.register( + r"full-time-bureaucrats", + FullTimeBureaucratViewSet, + basename="full-time-bureaucrat", +) +router.register( + r"examination-systems", + ExaminationSystemViewSet, + basename="examination-system", +) +router.register( + r"merit-promotions", MeritPromotionViewSet, basename="merit-promotion" +) +router.register( + r"specialized-government-buildings", + SpecializedGovernmentBuildingViewSet, + basename="specialized-government-building", +) +router.register( + r"formal-legal-codes", FormalLegalCodeViewSet, basename="formal-legal-code" +) +router.register(r"judges", JudgeViewSet, basename="judge") +router.register(r"courts", CourtViewSet, basename="court") +router.register( + r"professional-lawyers", + ProfessionalLawyerViewSet, + basename="professional-lawyer", +) +router.register( + r"irrigation-systems", + IrrigationSystemViewSet, + basename="irrigation-system", +) +router.register( + r"drinking-water-supplies", + DrinkingWaterSupplySystemViewSet, + basename="drinking-water-supply-system", +) +router.register(r"markets", MarketViewSet, basename="market") +router.register( + r"food-storage-sites", FoodStorageSiteViewSet, basename="food-storage-site" +) +router.register(r"roads", RoadViewSet, basename="road") +router.register(r"bridges", BridgeViewSet, basename="bridge") +router.register(r"canals", CanalViewSet, basename="canal") +router.register(r"ports", PortViewSet, basename="port") +router.register( + r"mines-or-quarries", MinesOrQuarryViewSet, basename="mines-or-quarry" +) +router.register( + r"mnemonic-devices", MnemonicDeviceViewSet, basename="mnemonic-device" +) +router.register( + r"nonwritten-records", + NonwrittenRecordViewSet, + basename="nonwritten-record", +) +router.register( + r"written-records", WrittenRecordViewSet, basename="written-record" +) +router.register(r"scripts", ScriptViewSet, basename="script") +router.register( + r"non-phonetic-writings", + NonPhoneticWritingViewSet, + basename="non-phonetic-writing", +) +router.register( + r"phonetic-alphabetic-writings", + PhoneticAlphabeticWritingViewSet, + basename="phonetic-alphabetic-writing", +) +router.register( + r"lists-tables-and-classifications", + ListsTablesAndClassificationViewSet, + basename="lists-tables-and-classifications", +) +router.register(r"calendars", CalendarViewSet, basename="calendar") +router.register(r"sacred-texts", SacredTextViewSet, basename="sacred-text") +router.register( + r"religious-literatures", + ReligiousLiteratureViewSet, + basename="religious-literature", +) +router.register( + r"practical-literatures", + PracticalLiteratureViewSet, + basename="practical-literature", +) +router.register(r"histories", HistoryViewSet, basename="history") +router.register(r"philosophies", PhilosophyViewSet, basename="philosophy") +router.register( + r"scientific-literatures", + ScientificLiteratureViewSet, + basename="scientific-literature", +) +router.register(r"fictions", FictionViewSet, basename="fiction") +router.register(r"articles", ArticleViewSet, basename="article") +router.register(r"tokens", TokenViewSet, basename="token") +router.register( + r"precious-metals", PreciousMetalViewSet, basename="precious-metal" +) +router.register(r"foreign-coins", ForeignCoinViewSet, basename="foreign-coin") +router.register( + r"indigenous-coins", IndigenousCoinViewSet, basename="indigenous-coin" +) +router.register( + r"paper-currencies", PaperCurrencyViewSet, basename="paper-currency" +) +router.register(r"couriers", CourierViewSet, basename="courier") +router.register( + r"postal-stations", PostalStationViewSet, basename="postal-station" +) +router.register( + r"general-postal-services", + GeneralPostalServiceViewSet, + basename="general-postal-service", +) +router.register( + r"communal-buildings", + CommunalBuildingViewSet, + basename="communal-building", +) +router.register( + r"utilitarian-public-buildings", + UtilitarianPublicBuildingViewSet, + basename="utilitarian-public-building", +) +router.register( + r"symbolic-buildings", + SymbolicBuildingViewSet, + basename="symbolic-building", +) +router.register( + r"entertainment-buildings", + EntertainmentBuildingViewSet, + basename="entertainment-building", +) +router.register( + r"knowledge-or-information-buildings", + KnowledgeOrInformationBuildingViewSet, + basename="knowledge-or-information-building", +) +router.register( + r"other-utilitarian-public-buildings", + OtherUtilitarianPublicBuildingViewSet, + basename="other-utilitarian-public-building", +) +router.register( + r"special-purpose-sites", + SpecialPurposeSiteViewSet, + basename="special-purpose-site", +) +router.register( + r"ceremonial-sites", CeremonialSiteViewSet, basename="ceremonial-site" +) +router.register(r"burial-sites", BurialSiteViewSet, basename="burial-site") +router.register( + r"trading-emporia", TradingEmporiaViewSet, basename="trading-emporium" +) +router.register(r"enclosures", EnclosureViewSet, basename="enclosure") +router.register( + r"length-measurement-systems", + LengthMeasurementSystemViewSet, + basename="length-measurement-system", +) +router.register( + r"area-measurement-systems", + AreaMeasurementSystemViewSet, + basename="area-measurement-system", +) +router.register( + r"volume-measurement-systems", + VolumeMeasurementSystemViewSet, + basename="volume-measurement-system", +) +router.register( + r"weight-measurement-systems", + WeightMeasurementSystemViewSet, + basename="weight-measurement-system", +) +router.register( + r"time-measurement-systems", + TimeMeasurementSystemViewSet, + basename="time-measurement-system", +) +router.register( + r"geometrical-measurement-systems", + GeometricalMeasurementSystemViewSet, + basename="geometrical-measurement-system", +) +router.register( + r"other-measurement-systems", + OtherMeasurementSystemViewSet, + basename="other-measurement-system", +) +router.register( + r"debt-and-credit-structures", + DebtAndCreditStructureViewSet, + basename="debt-and-credit-structure", +) +router.register( + r"stores-of-wealth", StoreOfWealthViewSet, basename="store-of-wealth" +) +router.register( + r"sources-of-support", SourceOfSupportViewSet, basename="source-of-support" +) +router.register( + r"occupational-complexities", + OccupationalComplexityViewSet, + basename="occupational-complexity", +) +router.register( + r"special-purpose-houses", + SpecialPurposeHouseViewSet, + basename="special-purpose-house", +) +router.register( + r"other-special-purpose-sites", + OtherSpecialPurposeSiteViewSet, + basename="other-special-purpose-site", +) +router.register( + r"largest-communication-distances", + LargestCommunicationDistanceViewSet, + basename="largest-communication-distance", +) +router.register( + r"fastest-individual-communications", + FastestIndividualCommunicationViewSet, + basename="fastest-individual-communication", +) + + +# Register views for "wf" app + +from .views.wf import ( + LongWallViewSet, + CopperViewSet, + BronzeViewSet, + IronViewSet, + SteelViewSet, + JavelinViewSet, + AtlatlViewSet, + SlingViewSet, + SelfBowViewSet, + CompositeBowViewSet, + CrossbowViewSet, + TensionSiegeEngineViewSet, + SlingSiegeEngineViewSet, + GunpowderSiegeArtilleryViewSet, + HandheldFirearmViewSet, + WarClubViewSet, + BattleAxeViewSet, + DaggerViewSet, + SwordViewSet, + SpearViewSet, + PolearmViewSet, + DogViewSet, + DonkeyViewSet, + HorseViewSet, + CamelViewSet, + ElephantViewSet, + WoodBarkEtcViewSet, + LeatherClothViewSet, + ShieldViewSet, + HelmetViewSet, + BreastplateViewSet, + LimbProtectionViewSet, + ScaledArmorViewSet, + LaminarArmorViewSet, + PlateArmorViewSet, + SmallVesselsCanoesEtcViewSet, + MerchantShipPressedIntoServiceViewSet, + SpecializedMilitaryVesselViewSet, + SettlementInADefensivePositionViewSet, + WoodenPalisadeViewSet, + EarthRampartViewSet, + DitchViewSet, + MoatViewSet, + StoneWallsNonMortaredViewSet, + StoneWallsMortaredViewSet, + FortifiedCampViewSet, + ComplexFortificationViewSet, + ModernFortificationViewSet, + ChainmailViewSet, +) + +router.register(r"long-walls", LongWallViewSet, basename="long-wall") +router.register(r"coppers", CopperViewSet, basename="copper") +router.register(r"bronzes", BronzeViewSet, basename="bronze") +router.register(r"irons", IronViewSet, basename="iron") +router.register(r"steels", SteelViewSet, basename="steel") +router.register(r"javelins", JavelinViewSet, basename="javelin") +router.register(r"atlatls", AtlatlViewSet, basename="atlatl") +router.register(r"slings", SlingViewSet, basename="sling") +router.register(r"self-bows", SelfBowViewSet, basename="self-bow") +router.register( + r"composite-bows", CompositeBowViewSet, basename="composite-bow" +) +router.register(r"crossbows", CrossbowViewSet, basename="crossbow") +router.register( + r"tension-siege-engines", + TensionSiegeEngineViewSet, + basename="tension-siege-engine", +) +router.register( + r"sling-siege-engines", + SlingSiegeEngineViewSet, + basename="sling-siege-engine", +) +router.register( + r"gunpowder-siege-artilleries", + GunpowderSiegeArtilleryViewSet, + basename="gunpowder-siege-artillery", +) +router.register( + r"handheld-firearms", HandheldFirearmViewSet, basename="handheld-firearm" +) +router.register(r"war-clubs", WarClubViewSet, basename="war-club") +router.register(r"battle-axes", BattleAxeViewSet, basename="battle-axe") +router.register(r"daggers", DaggerViewSet, basename="dagger") +router.register(r"swords", SwordViewSet, basename="sword") +router.register(r"spears", SpearViewSet, basename="spear") +router.register(r"polearms", PolearmViewSet, basename="polearm") +router.register(r"dogs", DogViewSet, basename="dog") +router.register(r"donkeys", DonkeyViewSet, basename="donkey") +router.register(r"horses", HorseViewSet, basename="horse") +router.register(r"camels", CamelViewSet, basename="camel") +router.register(r"elephants", ElephantViewSet, basename="elephant") +router.register(r"wood-bark-etc", WoodBarkEtcViewSet, basename="wood-bark-etc") +router.register(r"leathers", LeatherClothViewSet, basename="leather-cloth") +router.register(r"shields", ShieldViewSet, basename="shield") +router.register(r"helmets", HelmetViewSet, basename="helmet") +router.register(r"breastplates", BreastplateViewSet, basename="breastplate") +router.register( + r"limb-protections", LimbProtectionViewSet, basename="limb-protection" +) +router.register(r"scaled-armors", ScaledArmorViewSet, basename="scaled-armor") +router.register( + r"laminar-armors", LaminarArmorViewSet, basename="laminar-armor" +) +router.register(r"plate-armors", PlateArmorViewSet, basename="plate-armor") +router.register( + r"small-vessel-canoe-etc", + SmallVesselsCanoesEtcViewSet, + basename="small-vessel-canoe-etc", +) +router.register( + r"merchant-ship-pressed-into-service", + MerchantShipPressedIntoServiceViewSet, + basename="merchant-ship-pressed-into-service", +) +router.register( + r"specialized-military-vessels", + SpecializedMilitaryVesselViewSet, + basename="specialized-military-vessel", +) +router.register( + r"settlement-in-defensive-positions", + SettlementInADefensivePositionViewSet, + basename="settlement-in-defensive-position", +) +router.register( + r"wooden-palisades", WoodenPalisadeViewSet, basename="wooden-palisade" +) +router.register( + r"earth-ramparts", EarthRampartViewSet, basename="earth-rampart" +) +router.register(r"ditches", DitchViewSet, basename="ditch") +router.register(r"moats", MoatViewSet, basename="moat") +router.register( + r"stone-walls-non-mortared", + StoneWallsNonMortaredViewSet, + basename="stone-walls-non-mortared", +) +router.register( + r"stone-walls-mortared", + StoneWallsMortaredViewSet, + basename="stone-walls-mortared", +) +router.register( + r"fortified-camps", FortifiedCampViewSet, basename="fortified-camp" +) +router.register( + r"complex-fortifications", + ComplexFortificationViewSet, + basename="complex-fortification", +) +router.register( + r"modern-fortifications", + ModernFortificationViewSet, + basename="modern-fortification", +) +router.register(r"chainmails", ChainmailViewSet, basename="chainmail") + + +# Register all the views with the router + +urlpatterns = [ + path("", include(router.urls)), + path( + "api-auth/", include("rest_framework.urls", namespace="rest_framework") + ), ] -# urlpatterns = [ -# #path('/', VarDetail.as_view(), name='detailcreate'), -# #path('', VarList, name='api_home'), -# path('/', PolityDetail.as_view(), name='detailcreate'), -# path('', PolityList.as_view(), name='api_home'), -# ] - -# urlpatterns_with_suffix = [ -# path('refs/', views.reference_list), -# path('refs//', views.reference_detail), -# ] -# urlpatterns = format_suffix_patterns(urlpatterns_with_suffix) From 34bae083bea554a9fd05b5172e90375ac2d1a1df Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:08:29 +0100 Subject: [PATCH 07/16] Adding pagination on `account` app views --- seshat/apps/seshat_api/views/accounts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seshat/apps/seshat_api/views/accounts.py b/seshat/apps/seshat_api/views/accounts.py index dca7ff447..a11a37da9 100644 --- a/seshat/apps/seshat_api/views/accounts.py +++ b/seshat/apps/seshat_api/views/accounts.py @@ -5,6 +5,7 @@ from ._mixins import ( MixinSeshatAPIAuth, MixinSeshatAPISerializer, + SeshatAPIPagination, ) from ._permissions import ONLY_ADMIN_PERMISSIONS @@ -17,6 +18,7 @@ class ProfileViewSet( """ model = Profile + pagination_class = SeshatAPIPagination lookup_field = "user__username" permissions_dict = ONLY_ADMIN_PERMISSIONS @@ -29,6 +31,7 @@ class SeshatExpertViewSet( """ model = Seshat_Expert + pagination_class = SeshatAPIPagination lookup_field = "user__username" permissions_dict = ONLY_ADMIN_PERMISSIONS @@ -41,5 +44,6 @@ class SeshatTaskViewSet( """ model = Seshat_Task + pagination_class = SeshatAPIPagination permissions_dict = ONLY_ADMIN_PERMISSIONS fields = "__all__" From 3f4fa78e015ae5fba6eaf70d14d968eb9cd86898 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:13:55 +0100 Subject: [PATCH 08/16] Splitting URLs by Django app --- seshat/apps/seshat_api/urls.py | 455 ++++++++++++++++----------------- 1 file changed, 227 insertions(+), 228 deletions(-) diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index 6dd647889..c50105d61 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -14,13 +14,13 @@ SeshatTaskViewSet, ) -router.register(r"profiles", ProfileViewSet, basename="profile") +router.register(r"account/profiles", ProfileViewSet, basename="profile") router.register( - r"seshat-experts", + r"account/seshat-experts", SeshatExpertViewSet, basename="seshat-expert", ) -router.register(r"seshat-tasks", SeshatTaskViewSet, basename="seshat-task") +router.register(r"account/seshat-tasks", SeshatTaskViewSet, basename="seshat-task") # Register views for "core" app @@ -52,63 +52,63 @@ ) router.register( - r"private-comments", + r"core/private-comments", PrivateCommentsViewSet, basename="private-comment", ) router.register( - r"private-comments-parts", + r"core/private-comments-parts", PrivateCommentsPartsViewSet, basename="private-comment-part", ) -router.register(r"macro-regions", MacroRegionViewSet, basename="macro-region") -router.register(r"regions", RegionViewSet, basename="region") -router.register(r"ngas", NGAViewSet, basename="nga") -router.register(r"polities", PolityViewSet, basename="polity") -router.register(r"capitals", CapitalViewSet, basename="capital") +router.register(r"core/macro-regions", MacroRegionViewSet, basename="macro-region") +router.register(r"core/regions", RegionViewSet, basename="region") +router.register(r"core/ngas", NGAViewSet, basename="nga") +router.register(r"core/polities", PolityViewSet, basename="polity") +router.register(r"core/capitals", CapitalViewSet, basename="capital") router.register( - r"nga-polity-relations", + r"core/nga-polity-relations", NGAPolityRelationsViewSet, basename="nga-polity-relation", ) -router.register(r"countries", CountryViewSet, basename="country") -router.register(r"sections", SectionViewSet, basename="section") -router.register(r"subsections", SubsectionViewSet, basename="subsection") +router.register(r"core/countries", CountryViewSet, basename="country") +router.register(r"core/sections", SectionViewSet, basename="section") +router.register(r"core/subsections", SubsectionViewSet, basename="subsection") router.register( - r"variable-hierarchies", + r"core/variable-hierarchies", VariableHierarchyViewSet, basename="variable-hierarchy", ) -router.register(r"references", ReferenceViewSet, basename="reference") -router.register(r"citations", CitationViewSet, basename="citation") -router.register(r"comments", SeshatCommentViewSet, basename="seshat-comment") +router.register(r"core/references", ReferenceViewSet, basename="reference") +router.register(r"core/citations", CitationViewSet, basename="citation") +router.register(r"core/comments", SeshatCommentViewSet, basename="seshat-comment") router.register( - r"comment-parts", + r"core/comment-parts", SeshatCommentPartViewSet, basename="seshat-comment-part", ) router.register( - r"comment-parts-through-citations", + r"core/comment-parts-through-citations", ScpThroughCtnViewSet, basename="comment-part-through-citation", ) -router.register(r"commons", SeshatCommonViewSet, basename="common") -router.register(r"religions", ReligionViewSet, basename="religion") +router.register(r"core/commons", SeshatCommonViewSet, basename="common") +router.register(r"core/religions", ReligionViewSet, basename="religion") router.register( - r"video-shapefiles", + r"core/video-shapefiles", VideoShapefileViewSet, basename="video-shapefile", ) router.register( - r"gadm-shapefiles", + r"core/gadm-shapefiles", GADMShapefileViewSet, basename="gadm-shapefile", ) router.register( - r"gadm-countries", GADMCountriesViewSet, basename="gadm-country" + r"core/gadm-countries", GADMCountriesViewSet, basename="gadm-country" ) router.register( - r"gadm-provinces", + r"core/gadm-provinces", GADMProvincesViewSet, basename="gadm-province", ) @@ -145,118 +145,118 @@ DiseaseOutbreakViewSet, ) -router.register(r"us-locations", USLocationViewSet, basename="us-location") +router.register(r"crisisdb/us-locations", USLocationViewSet, basename="us-location") router.register( - r"us-violence-subtypes", + r"crisisdb/us-violence-subtypes", USViolenceSubtypeViewSet, basename="us-violence-subtype", ) router.register( - r"us-violence-data-sources", + r"crisisdb/us-violence-data-sources", USViolenceDataSourceViewSet, basename="us-violence-data-source", ) -router.register(r"us-violences", USViolenceViewSet, basename="us-violence") +router.register(r"crisisdb/us-violences", USViolenceViewSet, basename="us-violence") router.register( - r"crisis-consequences", + r"crisisdb/crisis-consequences", CrisisConsequenceViewSet, basename="crisis-consequence", ) router.register( - r"power-transitions", + r"crisisdb/power-transitions", PowerTransitionViewSet, basename="power-transition", ) router.register( - r"human-sacrifices", + r"crisisdb/human-sacrifices", HumanSacrificeViewSet, basename="human-sacrifice", ) router.register( - r"external-conflicts", + r"crisisdb/external-conflicts", ExternalConflictViewSet, basename="external-conflict", ) router.register( - r"external-conflict-sides", + r"crisisdb/external-conflict-sides", ExternalConflictSideViewSet, basename="external-conflict-side", ) router.register( - r"agricultural-populations", + r"crisisdb/agricultural-populations", AgriculturalPopulationViewSet, basename="agricultural-population", ) -router.register(r"arable-lands", ArableLandViewSet, basename="arable-land") +router.register(r"crisisdb/arable-lands", ArableLandViewSet, basename="arable-land") router.register( - r"arable-land-per-farmer", + r"crisisdb/arable-land-per-farmer", ArableLandPerFarmerViewSet, basename="arable-land-per-farmer", ) router.register( - r"gross-grain-shared-per-agricultural-populations", + r"crisisdb/gross-grain-shared-per-agricultural-populations", GrossGrainSharedPerAgriculturalPopulationViewSet, basename="gross-grain-shared-per-agricultural-population", ) router.register( - r"net-grain-shared-per-agricultural-populations", + r"crisisdb/net-grain-shared-per-agricultural-populations", NetGrainSharedPerAgriculturalPopulationViewSet, basename="net-grain-shared-per-agricultural-population", ) -router.register(r"surpluses", SurplusViewSet, basename="surplus") +router.register(r"crisisdb/surpluses", SurplusViewSet, basename="surplus") router.register( - r"military-expenses", + r"crisisdb/military-expenses", MilitaryExpenseViewSet, basename="military-expense", ) router.register( - r"silver-inflows", + r"crisisdb/silver-inflows", SilverInflowViewSet, basename="silver-inflow", ) router.register( - r"silver-stocks", + r"crisisdb/silver-stocks", SilverStockViewSet, basename="silver-stock", ) router.register( - r"total-populations", + r"crisisdb/total-populations", TotalPopulationViewSet, basename="total-population", ) router.register( - r"gdp-per-capitas", + r"crisisdb/gdp-per-capitas", GDPPerCapitaViewSet, basename="gdp-per-capita", ) router.register( - r"drought-events", + r"crisisdb/drought-events", DroughtEventViewSet, basename="drought-event", ) router.register( - r"locust-events", + r"crisisdb/locust-events", LocustEventViewSet, basename="locust-event", ) router.register( - r"socioeconomic-turmoil-events", + r"crisisdb/socioeconomic-turmoil-events", SocioeconomicTurmoilEventViewSet, basename="socioeconomic-turmoil-event", ) router.register( - r"crop-failure-events", + r"crisisdb/crop-failure-events", CropFailureEventViewSet, basename="crop-failure-event", ) router.register( - r"famine-events", + r"crisisdb/famine-events", FamineEventViewSet, basename="famine-event", ) router.register( - r"disease-outbreaks", + r"crisisdb/disease-outbreaks", DiseaseOutbreakViewSet, basename="disease-outbreak", ) @@ -294,118 +294,118 @@ ) router.register( - r"polity-research-assistants", + r"general/polity-research-assistants", PolityResearchAssistantViewSet, basename="polity-research-assistant", ) router.register( - r"polity-original-names", + r"general/polity-original-names", PolityOriginalNameViewSet, basename="polity-original-name", ) router.register( - r"polity-alternative-names", + r"general/polity-alternative-names", PolityAlternativeNameViewSet, basename="polity-alternative-name", ) router.register( - r"polity-durations", PolityDurationViewSet, basename="polity-duration" + r"general/polity-durations", PolityDurationViewSet, basename="polity-duration" ) router.register( - r"polity-peak-years", PolityPeakYearsViewSet, basename="polity-peak-years" + r"general/polity-peak-years", PolityPeakYearsViewSet, basename="polity-peak-years" ) router.register( - r"polity-degree-of-centralizations", + r"general/polity-degree-of-centralizations", PolityDegreeOfCentralizationViewSet, basename="polity-degree-of-centralization", ) router.register( - r"polity-suprapolities", + r"general/polity-suprapolities", PolitySuprapolityRelationsViewSet, basename="polity-suprapolity", ) router.register( - r"polity-utm-timezones", + r"general/polity-utm-timezones", PolityUTMZoneViewSet, basename="polity-utm-timezone", ) router.register( - r"polity-capitals", PolityCapitalViewSet, basename="polity-capital" + r"general/polity-capitals", PolityCapitalViewSet, basename="polity-capital" ) router.register( - r"polity-languages", PolityLanguageViewSet, basename="polity-language" + r"general/polity-languages", PolityLanguageViewSet, basename="polity-language" ) router.register( - r"polity-linguistic-families", + r"general/polity-linguistic-families", PolityLinguisticFamilyViewSet, basename="polity-linguistic-family", ) router.register( - r"polity-language-genuses", + r"general/polity-language-genuses", PolityLanguageGenusViewSet, basename="polity-language-genus", ) router.register( - r"polity-religion-genuses", + r"general/polity-religion-genuses", PolityReligionGenusViewSet, basename="polity-religion-genus", ) router.register( - r"polity-religion-families", + r"general/polity-religion-families", PolityReligionFamilyViewSet, basename="polity-religion-family", ) router.register( - r"polity-religions", PolityReligionViewSet, basename="polity-religion" + r"general/polity-religions", PolityReligionViewSet, basename="polity-religion" ) router.register( - r"polity-relationship-to-preceding-entities", + r"general/polity-relationship-to-preceding-entities", PolityRelationshipToPrecedingEntityViewSet, basename="polity-relationship-to-preceding-entity", ) router.register( - r"polity-preceding-entities", + r"general/polity-preceding-entities", PolityPrecedingEntityViewSet, basename="polity-preceding-entity", ) router.register( - r"polity-succeeding-entities", + r"general/polity-succeeding-entities", PolitySucceedingEntityViewSet, basename="polity-succeeding-entity", ) router.register( - r"polity-supracultural-entities", + r"general/polity-supracultural-entities", PolitySupraculturalEntityViewSet, basename="polity-supracultural-entity", ) router.register( - r"polity-scale-of-supracultural-interactions", + r"general/polity-scale-of-supracultural-interactions", PolityScaleOfSupraculturalInteractionViewSet, basename="polity-scale-of-supracultural-interaction", ) router.register( - r"polity-alternate-religion-genuses", + r"general/polity-alternate-religion-genuses", PolityAlternateReligionGenusViewSet, basename="polity-alternate-religion-genus", ) router.register( - r"polity-alternate-religion-families", + r"general/polity-alternate-religion-families", PolityAlternateReligionFamilyViewSet, basename="polity-alternate-religion-family", ) router.register( - r"polity-alternate-religions", + r"general/polity-alternate-religions", PolityAlternateReligionViewSet, basename="polity-alternate-religion", ) router.register( - r"polity-experts", PolityExpertViewSet, basename="polity-expert" + r"general/polity-experts", PolityExpertViewSet, basename="polity-expert" ) router.register( - r"polity-editors", PolityEditorViewSet, basename="polity-editor" + r"general/polity-editors", PolityEditorViewSet, basename="polity-editor" ) router.register( - r"polity-religious-traditions", + r"general/polity-religious-traditions", PolityReligiousTraditionViewSet, basename="polity-religious-tradition", ) @@ -438,109 +438,110 @@ ) router.register( - r"widespread-religions", + r"rt/widespread-religions", WidespreadReligionViewSet, basename="widespread-religion", ) router.register( - r"official-religions", + r"rt/official-religions", OfficialReligionViewSet, basename="official-religion", ) router.register( - r"elites-religions", ElitesReligionViewSet, basename="elites-religion" + r"rt/elites-religions", ElitesReligionViewSet, basename="elites-religion" ) router.register( - r"theological-syncretism-of-different-religions", + r"rt/theological-syncretism-of-different-religions", TheoSyncDifRelViewSet, basename="theological-syncretism-of-different-religions", ) router.register( - r"syncretism-of-religious-practices-at-the-level-of-individual-believers", + r"rt/syncretism-of-religious-practices-at-the-level-of-individual-believers", SyncRelPraIndBeliViewSet, basename="syncretism-of-religious-practices-at-the-level-of-individual-believers", ) router.register( - r"religious-fragmentations", + r"rt/religious-fragmentations", ReligiousFragmentationViewSet, basename="religious-fragmentation", ) router.register( - r"frequency-of-governmental-violence-against-religious-groups", + r"rt/frequency-of-governmental-violence-against-religious-groups", GovVioFreqRelGrpViewSet, basename="frequency-of-governmental-violence-against-religious-groups", ) router.register( - r"government-restrictions-on-public-worships", + r"rt/government-restrictions-on-public-worships", GovResPubWorViewSet, basename="government-restrictions-on-public-worships", ) router.register( - r"government-restrictions-on-public-proselytizings", + r"rt/government-restrictions-on-public-proselytizings", GovResPubProsViewSet, basename="government-restrictions-on-public-proselytizings", ) router.register( - r"government-restrictions-on-conversions", + r"rt/government-restrictions-on-conversions", GovResConvViewSet, basename="government-restrictions-on-conversions", ) router.register( - r"government-pressure-to-converts", + r"rt/government-pressure-to-converts", GovPressConvViewSet, basename="government-pressure-to-converts", ) router.register( - r"government-restrictions-on-property-ownership-for-adherents-of-and-religious-groups", + r"rt/government-restrictions-on-property-ownership-for-adherents-of-and-religious-groups", GovResPropOwnForRelGrpViewSet, basename="government-restrictions-on-property-ownership-for-adherents-of-and-religious-groups", ) router.register( - r"taxes-based-on-religious-adherence-or-on-religious-activities-and-institutions", + r"rt/taxes-based-on-religious-adherence-or-on-religious-activities-and-institutions", TaxRelAdhActInsViewSet, basename="taxes-based-on-religious-adherence-or-on-religious-activities-and-institutions", ) router.register( - r"governmental-obligations-for-religious-groups-to-apply-for-official-recognitions", + r"rt/governmental-obligations-for-religious-groups-to-apply-for-official-recognitions", GovOblRelGrpOfcRecoViewSet, basename="governmental-obligations-for-religious-groups-to-apply-for-official-recognitions", ) router.register( - r"government-restrictions-on-construction-of-religious-buildings", + r"rt/government-restrictions-on-construction-of-religious-buildings", GovResConsRelBuilViewSet, basename="government-restrictions-on-construction-of-religious-buildings", ) router.register( - r"government-restrictions-on-religious-educations", + r"rt/government-restrictions-on-religious-educations", GovResRelEduViewSet, basename="government-restrictions-on-religious-educations", ) router.register( - r"government-restrictions-on-circulation-of-religious-literatures", + r"rt/government-restrictions-on-circulation-of-religious-literatures", GovResCirRelLitViewSet, basename="government-restrictions-on-circulation-of-religious-literatures", ) router.register( - r"government-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", + r"rt/government-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", GovDisRelGrpOccFunViewSet, basename="government-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", ) router.register( - r"frequency-of-societal-violence-against-religious-groups", + r"rt/frequency-of-societal-violence-against-religious-groups", SocVioFreqRelGrpViewSet, basename="frequency-of-societal-violence-against-religious-groups", ) router.register( - r"societal-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", + r"rt/societal-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", SocDisRelGrpOccFunViewSet, basename="societal-discrimination-against-religious-groups-taking-up-certain-occupations-or-functions", ) router.register( - r"societal-pressure-to-convert-or-against-conversions", + r"rt/societal-pressure-to-convert-or-against-conversions", GovPressConvForAgaViewSet, basename="societal-pressure-to-convert-or-against-conversions", ) + # Add views for "sc" app to the router from .views.sc import ( @@ -624,283 +625,281 @@ FastestIndividualCommunicationViewSet, ) -# Register views for "sc" app - router.register( - r"research-assistants", RAViewSet, basename="research-assistant" + r"sc/research-assistants", RAViewSet, basename="research-assistant" ) router.register( - r"polity-territories", PolityTerritoryViewSet, basename="polity-territory" + r"sc/polity-territories", PolityTerritoryViewSet, basename="polity-territory" ) router.register( - r"polity-populations", + r"sc/polity-populations", PolityPopulationViewSet, basename="polity-population", ) router.register( - r"population-of-the-largest-settlements", + r"sc/population-of-the-largest-settlements", PopulationOfTheLargestSettlementViewSet, basename="population-of-the-largest-settlement", ) router.register( - r"settlement-hierarchies", + r"sc/settlement-hierarchies", SettlementHierarchyViewSet, basename="settlement-hierarchy", ) router.register( - r"administrative-levels", + r"sc/administrative-levels", AdministrativeLevelViewSet, basename="administrative-level", ) router.register( - r"religious-levels", ReligiousLevelViewSet, basename="religious-level" + r"sc/religious-levels", ReligiousLevelViewSet, basename="religious-level" ) router.register( - r"military-levels", MilitaryLevelViewSet, basename="military-level" + r"sc/military-levels", MilitaryLevelViewSet, basename="military-level" ) router.register( - r"professional-military-officers", + r"sc/professional-military-officers", ProfessionalMilitaryOfficerViewSet, basename="professional-military-officer", ) router.register( - r"professional-soldiers", + r"sc/professional-soldiers", ProfessionalSoldierViewSet, basename="professional-soldier", ) router.register( - r"professional-priesthoods", + r"sc/professional-priesthoods", ProfessionalPriesthoodViewSet, basename="professional-priesthood", ) router.register( - r"full-time-bureaucrats", + r"sc/full-time-bureaucrats", FullTimeBureaucratViewSet, basename="full-time-bureaucrat", ) router.register( - r"examination-systems", + r"sc/examination-systems", ExaminationSystemViewSet, basename="examination-system", ) router.register( - r"merit-promotions", MeritPromotionViewSet, basename="merit-promotion" + r"sc/merit-promotions", MeritPromotionViewSet, basename="merit-promotion" ) router.register( - r"specialized-government-buildings", + r"sc/specialized-government-buildings", SpecializedGovernmentBuildingViewSet, basename="specialized-government-building", ) router.register( - r"formal-legal-codes", FormalLegalCodeViewSet, basename="formal-legal-code" + r"sc/formal-legal-codes", FormalLegalCodeViewSet, basename="formal-legal-code" ) -router.register(r"judges", JudgeViewSet, basename="judge") -router.register(r"courts", CourtViewSet, basename="court") +router.register(r"sc/judges", JudgeViewSet, basename="judge") +router.register(r"sc/courts", CourtViewSet, basename="court") router.register( - r"professional-lawyers", + r"sc/professional-lawyers", ProfessionalLawyerViewSet, basename="professional-lawyer", ) router.register( - r"irrigation-systems", + r"sc/irrigation-systems", IrrigationSystemViewSet, basename="irrigation-system", ) router.register( - r"drinking-water-supplies", + r"sc/drinking-water-supplies", DrinkingWaterSupplySystemViewSet, basename="drinking-water-supply-system", ) -router.register(r"markets", MarketViewSet, basename="market") +router.register(r"sc/markets", MarketViewSet, basename="market") router.register( - r"food-storage-sites", FoodStorageSiteViewSet, basename="food-storage-site" + r"sc/food-storage-sites", FoodStorageSiteViewSet, basename="food-storage-site" ) -router.register(r"roads", RoadViewSet, basename="road") -router.register(r"bridges", BridgeViewSet, basename="bridge") -router.register(r"canals", CanalViewSet, basename="canal") -router.register(r"ports", PortViewSet, basename="port") +router.register(r"sc/roads", RoadViewSet, basename="road") +router.register(r"sc/bridges", BridgeViewSet, basename="bridge") +router.register(r"sc/canals", CanalViewSet, basename="canal") +router.register(r"sc/ports", PortViewSet, basename="port") router.register( - r"mines-or-quarries", MinesOrQuarryViewSet, basename="mines-or-quarry" + r"sc/mines-or-quarries", MinesOrQuarryViewSet, basename="mines-or-quarry" ) router.register( - r"mnemonic-devices", MnemonicDeviceViewSet, basename="mnemonic-device" + r"sc/mnemonic-devices", MnemonicDeviceViewSet, basename="mnemonic-device" ) router.register( - r"nonwritten-records", + r"sc/nonwritten-records", NonwrittenRecordViewSet, basename="nonwritten-record", ) router.register( - r"written-records", WrittenRecordViewSet, basename="written-record" + r"sc/written-records", WrittenRecordViewSet, basename="written-record" ) -router.register(r"scripts", ScriptViewSet, basename="script") +router.register(r"sc/scripts", ScriptViewSet, basename="script") router.register( - r"non-phonetic-writings", + r"sc/non-phonetic-writings", NonPhoneticWritingViewSet, basename="non-phonetic-writing", ) router.register( - r"phonetic-alphabetic-writings", + r"sc/phonetic-alphabetic-writings", PhoneticAlphabeticWritingViewSet, basename="phonetic-alphabetic-writing", ) router.register( - r"lists-tables-and-classifications", + r"sc/lists-tables-and-classifications", ListsTablesAndClassificationViewSet, basename="lists-tables-and-classifications", ) -router.register(r"calendars", CalendarViewSet, basename="calendar") -router.register(r"sacred-texts", SacredTextViewSet, basename="sacred-text") +router.register(r"sc/calendars", CalendarViewSet, basename="calendar") +router.register(r"sc/sacred-texts", SacredTextViewSet, basename="sacred-text") router.register( - r"religious-literatures", + r"sc/religious-literatures", ReligiousLiteratureViewSet, basename="religious-literature", ) router.register( - r"practical-literatures", + r"sc/practical-literatures", PracticalLiteratureViewSet, basename="practical-literature", ) -router.register(r"histories", HistoryViewSet, basename="history") -router.register(r"philosophies", PhilosophyViewSet, basename="philosophy") +router.register(r"sc/histories", HistoryViewSet, basename="history") +router.register(r"sc/philosophies", PhilosophyViewSet, basename="philosophy") router.register( - r"scientific-literatures", + r"sc/scientific-literatures", ScientificLiteratureViewSet, basename="scientific-literature", ) -router.register(r"fictions", FictionViewSet, basename="fiction") -router.register(r"articles", ArticleViewSet, basename="article") -router.register(r"tokens", TokenViewSet, basename="token") +router.register(r"sc/fictions", FictionViewSet, basename="fiction") +router.register(r"sc/articles", ArticleViewSet, basename="article") +router.register(r"sc/tokens", TokenViewSet, basename="token") router.register( - r"precious-metals", PreciousMetalViewSet, basename="precious-metal" + r"sc/precious-metals", PreciousMetalViewSet, basename="precious-metal" ) -router.register(r"foreign-coins", ForeignCoinViewSet, basename="foreign-coin") +router.register(r"sc/foreign-coins", ForeignCoinViewSet, basename="foreign-coin") router.register( - r"indigenous-coins", IndigenousCoinViewSet, basename="indigenous-coin" + r"sc/indigenous-coins", IndigenousCoinViewSet, basename="indigenous-coin" ) router.register( - r"paper-currencies", PaperCurrencyViewSet, basename="paper-currency" + r"sc/paper-currencies", PaperCurrencyViewSet, basename="paper-currency" ) -router.register(r"couriers", CourierViewSet, basename="courier") +router.register(r"sc/couriers", CourierViewSet, basename="courier") router.register( - r"postal-stations", PostalStationViewSet, basename="postal-station" + r"sc/postal-stations", PostalStationViewSet, basename="postal-station" ) router.register( - r"general-postal-services", + r"sc/general-postal-services", GeneralPostalServiceViewSet, basename="general-postal-service", ) router.register( - r"communal-buildings", + r"sc/communal-buildings", CommunalBuildingViewSet, basename="communal-building", ) router.register( - r"utilitarian-public-buildings", + r"sc/utilitarian-public-buildings", UtilitarianPublicBuildingViewSet, basename="utilitarian-public-building", ) router.register( - r"symbolic-buildings", + r"sc/symbolic-buildings", SymbolicBuildingViewSet, basename="symbolic-building", ) router.register( - r"entertainment-buildings", + r"sc/entertainment-buildings", EntertainmentBuildingViewSet, basename="entertainment-building", ) router.register( - r"knowledge-or-information-buildings", + r"sc/knowledge-or-information-buildings", KnowledgeOrInformationBuildingViewSet, basename="knowledge-or-information-building", ) router.register( - r"other-utilitarian-public-buildings", + r"sc/other-utilitarian-public-buildings", OtherUtilitarianPublicBuildingViewSet, basename="other-utilitarian-public-building", ) router.register( - r"special-purpose-sites", + r"sc/special-purpose-sites", SpecialPurposeSiteViewSet, basename="special-purpose-site", ) router.register( - r"ceremonial-sites", CeremonialSiteViewSet, basename="ceremonial-site" + r"sc/ceremonial-sites", CeremonialSiteViewSet, basename="ceremonial-site" ) -router.register(r"burial-sites", BurialSiteViewSet, basename="burial-site") +router.register(r"sc/burial-sites", BurialSiteViewSet, basename="burial-site") router.register( - r"trading-emporia", TradingEmporiaViewSet, basename="trading-emporium" + r"sc/trading-emporia", TradingEmporiaViewSet, basename="trading-emporium" ) -router.register(r"enclosures", EnclosureViewSet, basename="enclosure") +router.register(r"sc/enclosures", EnclosureViewSet, basename="enclosure") router.register( - r"length-measurement-systems", + r"sc/length-measurement-systems", LengthMeasurementSystemViewSet, basename="length-measurement-system", ) router.register( - r"area-measurement-systems", + r"sc/area-measurement-systems", AreaMeasurementSystemViewSet, basename="area-measurement-system", ) router.register( - r"volume-measurement-systems", + r"sc/volume-measurement-systems", VolumeMeasurementSystemViewSet, basename="volume-measurement-system", ) router.register( - r"weight-measurement-systems", + r"sc/weight-measurement-systems", WeightMeasurementSystemViewSet, basename="weight-measurement-system", ) router.register( - r"time-measurement-systems", + r"sc/time-measurement-systems", TimeMeasurementSystemViewSet, basename="time-measurement-system", ) router.register( - r"geometrical-measurement-systems", + r"sc/geometrical-measurement-systems", GeometricalMeasurementSystemViewSet, basename="geometrical-measurement-system", ) router.register( - r"other-measurement-systems", + r"sc/other-measurement-systems", OtherMeasurementSystemViewSet, basename="other-measurement-system", ) router.register( - r"debt-and-credit-structures", + r"sc/debt-and-credit-structures", DebtAndCreditStructureViewSet, basename="debt-and-credit-structure", ) router.register( - r"stores-of-wealth", StoreOfWealthViewSet, basename="store-of-wealth" + r"sc/stores-of-wealth", StoreOfWealthViewSet, basename="store-of-wealth" ) router.register( - r"sources-of-support", SourceOfSupportViewSet, basename="source-of-support" + r"sc/sources-of-support", SourceOfSupportViewSet, basename="source-of-support" ) router.register( - r"occupational-complexities", + r"sc/occupational-complexities", OccupationalComplexityViewSet, basename="occupational-complexity", ) router.register( - r"special-purpose-houses", + r"sc/special-purpose-houses", SpecialPurposeHouseViewSet, basename="special-purpose-house", ) router.register( - r"other-special-purpose-sites", + r"sc/other-special-purpose-sites", OtherSpecialPurposeSiteViewSet, basename="other-special-purpose-site", ) router.register( - r"largest-communication-distances", + r"sc/largest-communication-distances", LargestCommunicationDistanceViewSet, basename="largest-communication-distance", ) router.register( - r"fastest-individual-communications", + r"sc/fastest-individual-communications", FastestIndividualCommunicationViewSet, basename="fastest-individual-communication", ) @@ -960,113 +959,113 @@ ChainmailViewSet, ) -router.register(r"long-walls", LongWallViewSet, basename="long-wall") -router.register(r"coppers", CopperViewSet, basename="copper") -router.register(r"bronzes", BronzeViewSet, basename="bronze") -router.register(r"irons", IronViewSet, basename="iron") -router.register(r"steels", SteelViewSet, basename="steel") -router.register(r"javelins", JavelinViewSet, basename="javelin") -router.register(r"atlatls", AtlatlViewSet, basename="atlatl") -router.register(r"slings", SlingViewSet, basename="sling") -router.register(r"self-bows", SelfBowViewSet, basename="self-bow") +router.register(r"wf/long-walls", LongWallViewSet, basename="long-wall") +router.register(r"wf/coppers", CopperViewSet, basename="copper") +router.register(r"wf/bronzes", BronzeViewSet, basename="bronze") +router.register(r"wf/irons", IronViewSet, basename="iron") +router.register(r"wf/steels", SteelViewSet, basename="steel") +router.register(r"wf/javelins", JavelinViewSet, basename="javelin") +router.register(r"wf/atlatls", AtlatlViewSet, basename="atlatl") +router.register(r"wf/slings", SlingViewSet, basename="sling") +router.register(r"wf/self-bows", SelfBowViewSet, basename="self-bow") router.register( - r"composite-bows", CompositeBowViewSet, basename="composite-bow" + r"wf/composite-bows", CompositeBowViewSet, basename="composite-bow" ) -router.register(r"crossbows", CrossbowViewSet, basename="crossbow") +router.register(r"wf/crossbows", CrossbowViewSet, basename="crossbow") router.register( - r"tension-siege-engines", + r"wf/tension-siege-engines", TensionSiegeEngineViewSet, basename="tension-siege-engine", ) router.register( - r"sling-siege-engines", + r"wf/sling-siege-engines", SlingSiegeEngineViewSet, basename="sling-siege-engine", ) router.register( - r"gunpowder-siege-artilleries", + r"wf/gunpowder-siege-artilleries", GunpowderSiegeArtilleryViewSet, basename="gunpowder-siege-artillery", ) router.register( - r"handheld-firearms", HandheldFirearmViewSet, basename="handheld-firearm" + r"wf/handheld-firearms", HandheldFirearmViewSet, basename="handheld-firearm" ) -router.register(r"war-clubs", WarClubViewSet, basename="war-club") -router.register(r"battle-axes", BattleAxeViewSet, basename="battle-axe") -router.register(r"daggers", DaggerViewSet, basename="dagger") -router.register(r"swords", SwordViewSet, basename="sword") -router.register(r"spears", SpearViewSet, basename="spear") -router.register(r"polearms", PolearmViewSet, basename="polearm") -router.register(r"dogs", DogViewSet, basename="dog") -router.register(r"donkeys", DonkeyViewSet, basename="donkey") -router.register(r"horses", HorseViewSet, basename="horse") -router.register(r"camels", CamelViewSet, basename="camel") -router.register(r"elephants", ElephantViewSet, basename="elephant") -router.register(r"wood-bark-etc", WoodBarkEtcViewSet, basename="wood-bark-etc") -router.register(r"leathers", LeatherClothViewSet, basename="leather-cloth") -router.register(r"shields", ShieldViewSet, basename="shield") -router.register(r"helmets", HelmetViewSet, basename="helmet") -router.register(r"breastplates", BreastplateViewSet, basename="breastplate") +router.register(r"wf/war-clubs", WarClubViewSet, basename="war-club") +router.register(r"wf/battle-axes", BattleAxeViewSet, basename="battle-axe") +router.register(r"wf/daggers", DaggerViewSet, basename="dagger") +router.register(r"wf/swords", SwordViewSet, basename="sword") +router.register(r"wf/spears", SpearViewSet, basename="spear") +router.register(r"wf/polearms", PolearmViewSet, basename="polearm") +router.register(r"wf/dogs", DogViewSet, basename="dog") +router.register(r"wf/donkeys", DonkeyViewSet, basename="donkey") +router.register(r"wf/horses", HorseViewSet, basename="horse") +router.register(r"wf/camels", CamelViewSet, basename="camel") +router.register(r"wf/elephants", ElephantViewSet, basename="elephant") +router.register(r"wf/wood-bark-etc", WoodBarkEtcViewSet, basename="wood-bark-etc") +router.register(r"wf/leathers", LeatherClothViewSet, basename="leather-cloth") +router.register(r"wf/shields", ShieldViewSet, basename="shield") +router.register(r"wf/helmets", HelmetViewSet, basename="helmet") +router.register(r"wf/breastplates", BreastplateViewSet, basename="breastplate") router.register( - r"limb-protections", LimbProtectionViewSet, basename="limb-protection" + r"wf/limb-protections", LimbProtectionViewSet, basename="limb-protection" ) -router.register(r"scaled-armors", ScaledArmorViewSet, basename="scaled-armor") +router.register(r"wf/scaled-armors", ScaledArmorViewSet, basename="scaled-armor") router.register( - r"laminar-armors", LaminarArmorViewSet, basename="laminar-armor" + r"wf/laminar-armors", LaminarArmorViewSet, basename="laminar-armor" ) -router.register(r"plate-armors", PlateArmorViewSet, basename="plate-armor") +router.register(r"wf/plate-armors", PlateArmorViewSet, basename="plate-armor") router.register( - r"small-vessel-canoe-etc", + r"wf/small-vessel-canoe-etc", SmallVesselsCanoesEtcViewSet, basename="small-vessel-canoe-etc", ) router.register( - r"merchant-ship-pressed-into-service", + r"wf/merchant-ship-pressed-into-service", MerchantShipPressedIntoServiceViewSet, basename="merchant-ship-pressed-into-service", ) router.register( - r"specialized-military-vessels", + r"wf/specialized-military-vessels", SpecializedMilitaryVesselViewSet, basename="specialized-military-vessel", ) router.register( - r"settlement-in-defensive-positions", + r"wf/settlement-in-defensive-positions", SettlementInADefensivePositionViewSet, basename="settlement-in-defensive-position", ) router.register( - r"wooden-palisades", WoodenPalisadeViewSet, basename="wooden-palisade" + r"wf/wooden-palisades", WoodenPalisadeViewSet, basename="wooden-palisade" ) router.register( - r"earth-ramparts", EarthRampartViewSet, basename="earth-rampart" + r"wf/earth-ramparts", EarthRampartViewSet, basename="earth-rampart" ) -router.register(r"ditches", DitchViewSet, basename="ditch") -router.register(r"moats", MoatViewSet, basename="moat") +router.register(r"wf/ditches", DitchViewSet, basename="ditch") +router.register(r"wf/moats", MoatViewSet, basename="moat") router.register( - r"stone-walls-non-mortared", + r"wf/stone-walls-non-mortared", StoneWallsNonMortaredViewSet, basename="stone-walls-non-mortared", ) router.register( - r"stone-walls-mortared", + r"wf/stone-walls-mortared", StoneWallsMortaredViewSet, basename="stone-walls-mortared", ) router.register( - r"fortified-camps", FortifiedCampViewSet, basename="fortified-camp" + r"wf/fortified-camps", FortifiedCampViewSet, basename="fortified-camp" ) router.register( - r"complex-fortifications", + r"wf/complex-fortifications", ComplexFortificationViewSet, basename="complex-fortification", ) router.register( - r"modern-fortifications", + r"wf/modern-fortifications", ModernFortificationViewSet, basename="modern-fortification", ) -router.register(r"chainmails", ChainmailViewSet, basename="chainmail") +router.register(r"wf/chainmails", ChainmailViewSet, basename="chainmail") # Register all the views with the router From 65d42b546cbd8587173cc4926d8857fe9e701e81 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:19:06 +0100 Subject: [PATCH 09/16] Fixing docstrings in `rt` viewsets --- seshat/apps/seshat_api/views/rt.py | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/seshat/apps/seshat_api/views/rt.py b/seshat/apps/seshat_api/views/rt.py index cfdef6c76..99e37b6e0 100644 --- a/seshat/apps/seshat_api/views/rt.py +++ b/seshat/apps/seshat_api/views/rt.py @@ -65,7 +65,7 @@ class TheoSyncDifRelViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Theo Sync Dif Rels. + A viewset for viewing and editing Theological Syncretism of Different Religions. """ model = Theo_sync_dif_rel pagination_class = SeshatAPIPagination @@ -75,7 +75,7 @@ class SyncRelPraIndBeliViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Sync Rel Pra Ind Belis. + A viewset for viewing and editing Syncretism of Religious Practices at the Level of Individual Believers. """ model = Sync_rel_pra_ind_beli pagination_class = SeshatAPIPagination @@ -95,7 +95,7 @@ class GovVioFreqRelGrpViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Vio Freq Rel Grps. + A viewset for viewing and editing Frequency of Governmental Violence Against Religious Groups. """ model = Gov_vio_freq_rel_grp pagination_class = SeshatAPIPagination @@ -105,7 +105,7 @@ class GovResPubWorViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Pub Wors. + A viewset for viewing and editing Government Restrictions on Public Worships. """ model = Gov_res_pub_wor pagination_class = SeshatAPIPagination @@ -115,7 +115,7 @@ class GovResPubProsViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Pub Proses. + A viewset for viewing and editing Government Restrictions on Public Proselytizings. """ model = Gov_res_pub_pros pagination_class = SeshatAPIPagination @@ -125,7 +125,7 @@ class GovResConvViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Convs. + A viewset for viewing and editing Government Restrictions on Conversions. """ model = Gov_res_conv pagination_class = SeshatAPIPagination @@ -135,7 +135,7 @@ class GovPressConvViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Press Convs. + A viewset for viewing and editing Government Pressures to Converts. """ model = Gov_press_conv pagination_class = SeshatAPIPagination @@ -145,7 +145,7 @@ class GovResPropOwnForRelGrpViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Prop Own For Rel Grps. + A viewset for viewing and editing Government Restrictions on Property Ownership for Adherents of and Religious Groups. """ model = Gov_res_prop_own_for_rel_grp pagination_class = SeshatAPIPagination @@ -155,7 +155,7 @@ class TaxRelAdhActInsViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Tax Rel Adh Act Inses. + A viewset for viewing and editing Taxes Based on Religious Adherence or on Religious Activities and Institutions. """ model = Tax_rel_adh_act_ins pagination_class = SeshatAPIPagination @@ -165,7 +165,7 @@ class GovOblRelGrpOfcRecoViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Obl Rel Grp Ofc Recos. + A viewset for viewing and editing Governmental Obligations for Religious Groups to Apply for Official Recognitions. """ model = Gov_obl_rel_grp_ofc_reco pagination_class = SeshatAPIPagination @@ -175,7 +175,7 @@ class GovResConsRelBuilViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Cons Rel Buils. + A viewset for viewing and editing Government Restrictions on Construction of Religious Buildings. """ model = Gov_res_cons_rel_buil pagination_class = SeshatAPIPagination @@ -185,7 +185,7 @@ class GovResRelEduViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Rel Edus. + A viewset for viewing and editing Government Restrictions on Religious Education. """ model = Gov_res_rel_edu pagination_class = SeshatAPIPagination @@ -195,7 +195,7 @@ class GovResCirRelLitViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Res Cir Rel Lits. + A viewset for viewing and editing Government Restrictions on Circulation of Religious Literature. """ model = Gov_res_cir_rel_lit pagination_class = SeshatAPIPagination @@ -205,7 +205,7 @@ class GovDisRelGrpOccFunViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Dis Rel Grp Occ Funs. + A viewset for viewing and editing Government Discrimination Against Religious Groups Taking Up Certain Occupations or Functions. """ model = Gov_dis_rel_grp_occ_fun pagination_class = SeshatAPIPagination @@ -215,7 +215,7 @@ class SocVioFreqRelGrpViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Soc Vio Freq Rel Grps. + A viewset for viewing and editing Social Violence Against Religious Groups. """ model = Soc_vio_freq_rel_grp pagination_class = SeshatAPIPagination @@ -225,7 +225,7 @@ class SocDisRelGrpOccFunViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Soc Dis Rel Grp Occ Funs. + A viewset for viewing and editing Social Discrimination Against Religious Groups Taking Up Certain Occupations or Functions. """ model = Soc_dis_rel_grp_occ_fun pagination_class = SeshatAPIPagination @@ -235,7 +235,7 @@ class GovPressConvForAgaViewSet( MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet ): """ - A viewset for viewing and editing Gov Press Conv For Agas. + A viewset for viewing and editing Societal Pressure to Convert or Against Conversions. """ model = Gov_press_conv_for_aga pagination_class = SeshatAPIPagination From 939dcdd7d04d87d80fad61e83f703ffda7b116a9 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:19:34 +0100 Subject: [PATCH 10/16] Formatting --- seshat/apps/seshat_api/views/rt.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/seshat/apps/seshat_api/views/rt.py b/seshat/apps/seshat_api/views/rt.py index 99e37b6e0..8b95bb4e5 100644 --- a/seshat/apps/seshat_api/views/rt.py +++ b/seshat/apps/seshat_api/views/rt.py @@ -37,6 +37,7 @@ class WidespreadReligionViewSet( """ A viewset for viewing and editing Widespread Religions. """ + model = Widespread_religion pagination_class = SeshatAPIPagination @@ -47,6 +48,7 @@ class OfficialReligionViewSet( """ A viewset for viewing and editing Official Religions. """ + model = Official_religion pagination_class = SeshatAPIPagination @@ -57,6 +59,7 @@ class ElitesReligionViewSet( """ A viewset for viewing and editing Elites Religions. """ + model = Elites_religion pagination_class = SeshatAPIPagination @@ -67,6 +70,7 @@ class TheoSyncDifRelViewSet( """ A viewset for viewing and editing Theological Syncretism of Different Religions. """ + model = Theo_sync_dif_rel pagination_class = SeshatAPIPagination @@ -77,6 +81,7 @@ class SyncRelPraIndBeliViewSet( """ A viewset for viewing and editing Syncretism of Religious Practices at the Level of Individual Believers. """ + model = Sync_rel_pra_ind_beli pagination_class = SeshatAPIPagination @@ -87,6 +92,7 @@ class ReligiousFragmentationViewSet( """ A viewset for viewing and editing Religious Fragmentations. """ + model = Religious_fragmentation pagination_class = SeshatAPIPagination @@ -97,6 +103,7 @@ class GovVioFreqRelGrpViewSet( """ A viewset for viewing and editing Frequency of Governmental Violence Against Religious Groups. """ + model = Gov_vio_freq_rel_grp pagination_class = SeshatAPIPagination @@ -107,6 +114,7 @@ class GovResPubWorViewSet( """ A viewset for viewing and editing Government Restrictions on Public Worships. """ + model = Gov_res_pub_wor pagination_class = SeshatAPIPagination @@ -117,6 +125,7 @@ class GovResPubProsViewSet( """ A viewset for viewing and editing Government Restrictions on Public Proselytizings. """ + model = Gov_res_pub_pros pagination_class = SeshatAPIPagination @@ -127,6 +136,7 @@ class GovResConvViewSet( """ A viewset for viewing and editing Government Restrictions on Conversions. """ + model = Gov_res_conv pagination_class = SeshatAPIPagination @@ -137,6 +147,7 @@ class GovPressConvViewSet( """ A viewset for viewing and editing Government Pressures to Converts. """ + model = Gov_press_conv pagination_class = SeshatAPIPagination @@ -147,6 +158,7 @@ class GovResPropOwnForRelGrpViewSet( """ A viewset for viewing and editing Government Restrictions on Property Ownership for Adherents of and Religious Groups. """ + model = Gov_res_prop_own_for_rel_grp pagination_class = SeshatAPIPagination @@ -157,6 +169,7 @@ class TaxRelAdhActInsViewSet( """ A viewset for viewing and editing Taxes Based on Religious Adherence or on Religious Activities and Institutions. """ + model = Tax_rel_adh_act_ins pagination_class = SeshatAPIPagination @@ -167,6 +180,7 @@ class GovOblRelGrpOfcRecoViewSet( """ A viewset for viewing and editing Governmental Obligations for Religious Groups to Apply for Official Recognitions. """ + model = Gov_obl_rel_grp_ofc_reco pagination_class = SeshatAPIPagination @@ -177,6 +191,7 @@ class GovResConsRelBuilViewSet( """ A viewset for viewing and editing Government Restrictions on Construction of Religious Buildings. """ + model = Gov_res_cons_rel_buil pagination_class = SeshatAPIPagination @@ -187,6 +202,7 @@ class GovResRelEduViewSet( """ A viewset for viewing and editing Government Restrictions on Religious Education. """ + model = Gov_res_rel_edu pagination_class = SeshatAPIPagination @@ -197,6 +213,7 @@ class GovResCirRelLitViewSet( """ A viewset for viewing and editing Government Restrictions on Circulation of Religious Literature. """ + model = Gov_res_cir_rel_lit pagination_class = SeshatAPIPagination @@ -207,6 +224,7 @@ class GovDisRelGrpOccFunViewSet( """ A viewset for viewing and editing Government Discrimination Against Religious Groups Taking Up Certain Occupations or Functions. """ + model = Gov_dis_rel_grp_occ_fun pagination_class = SeshatAPIPagination @@ -217,6 +235,7 @@ class SocVioFreqRelGrpViewSet( """ A viewset for viewing and editing Social Violence Against Religious Groups. """ + model = Soc_vio_freq_rel_grp pagination_class = SeshatAPIPagination @@ -227,6 +246,7 @@ class SocDisRelGrpOccFunViewSet( """ A viewset for viewing and editing Social Discrimination Against Religious Groups Taking Up Certain Occupations or Functions. """ + model = Soc_dis_rel_grp_occ_fun pagination_class = SeshatAPIPagination @@ -237,5 +257,6 @@ class GovPressConvForAgaViewSet( """ A viewset for viewing and editing Societal Pressure to Convert or Against Conversions. """ + model = Gov_press_conv_for_aga pagination_class = SeshatAPIPagination From a26becb976b67dd7d7b9ebd1f432ee77c9cc8d32 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 21 Jun 2024 15:31:07 +0100 Subject: [PATCH 11/16] Cleaning up --- seshat/apps/seshat_api/urls.py | 5 +++-- seshat/apps/seshat_api/views/_mixins.py | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index c50105d61..82f50e430 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -1,13 +1,14 @@ from django.urls import path, include from rest_framework import routers -from . import views # temp -- remove -# Create router for URLS +# Create router for URLs + router = routers.DefaultRouter() # Register viewsets for "account" app + from .views.accounts import ( ProfileViewSet, SeshatExpertViewSet, diff --git a/seshat/apps/seshat_api/views/_mixins.py b/seshat/apps/seshat_api/views/_mixins.py index 49ac8130f..f9ecc98da 100644 --- a/seshat/apps/seshat_api/views/_mixins.py +++ b/seshat/apps/seshat_api/views/_mixins.py @@ -2,9 +2,8 @@ from rest_framework.permissions import IsAuthenticated, AllowAny from ..serializers import GeneralSerializer -from rest_framework.serializers import HyperlinkedRelatedField -STANDARD_API_AUTHENTICATION = { +STANDARD_API_PERMISSION = { "HEAD": [AllowAny], "OPTIONS": [AllowAny], "GET": [AllowAny], @@ -13,7 +12,7 @@ "PATCH": [IsAuthenticated], "DELETE": [IsAuthenticated], } -"""Defines the standard authentication for the API, if no other is specified in the view.""" +"""Defines the standard permission for the API, if no other is specified in the view.""" class SeshatAPIPagination(PageNumberPagination): @@ -33,7 +32,7 @@ def get_permissions(self): try: permissions_dict = self.permissions_dict except AttributeError: - permissions_dict = STANDARD_API_AUTHENTICATION + permissions_dict = STANDARD_API_PERMISSION return [ permission() From cd624b01466d4e80e206a00723daaae8bc08473a Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Mon, 1 Jul 2024 14:32:19 +0100 Subject: [PATCH 12/16] Adding in token authentication --- seshat/apps/seshat_api/urls.py | 5 +++++ seshat/settings/base.py | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index 82f50e430..e1e63a57d 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -1077,3 +1077,8 @@ "api-auth/", include("rest_framework.urls", namespace="rest_framework") ), ] + +from rest_framework.authtoken import views +urlpatterns += [ + path('api-token-auth/', views.obtain_auth_token) +] \ No newline at end of file diff --git a/seshat/settings/base.py b/seshat/settings/base.py index 4b0cb10c2..6c66f29ab 100644 --- a/seshat/settings/base.py +++ b/seshat/settings/base.py @@ -3,10 +3,10 @@ import os -import django_heroku +# import django_heroku -import dj_database_url -from decouple import Csv, config +# import dj_database_url +from decouple import config import sys from django.contrib.messages import constants as messages @@ -79,6 +79,7 @@ 'django.contrib.gis', 'leaflet', #'easyaudit', + 'rest_framework.authtoken' ] AUTHENTICATION_BACKENDS = [ @@ -351,6 +352,10 @@ 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny', ], + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + 'rest_framework.authentication.SessionAuthentication', + ), } # CORS ALLOWED ORIGINS @@ -364,7 +369,7 @@ #LOGOUT_REDIRECT_URL = 'logout' # I believe this says: Hey Heroku, do your local settings, don't care about my static_root, static_url etc. -django_heroku.settings(locals()) +# django_heroku.settings(locals()) #print("###################") #print(STATICFILES_DIRS) #print(STATIC_ROOT) From ab997239ac7d37763dfc6ef5906ec46eb49849aa Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Tue, 2 Jul 2024 10:10:30 +0100 Subject: [PATCH 13/16] Removing routing to `Common` model --- seshat/apps/seshat_api/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index e1e63a57d..9ec19c3ce 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -93,7 +93,7 @@ ScpThroughCtnViewSet, basename="comment-part-through-citation", ) -router.register(r"core/commons", SeshatCommonViewSet, basename="common") +#router.register(r"core/commons", SeshatCommonViewSet, basename="common") router.register(r"core/religions", ReligionViewSet, basename="religion") router.register( r"core/video-shapefiles", From 026250aef10091e57d2b30ecb222f348399003b9 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Thu, 4 Jul 2024 19:24:10 +0100 Subject: [PATCH 14/16] Adding explanation for "NGA" --- seshat/apps/seshat_api/views/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/seshat_api/views/core.py b/seshat/apps/seshat_api/views/core.py index 51c3f5959..50df3a1f6 100644 --- a/seshat/apps/seshat_api/views/core.py +++ b/seshat/apps/seshat_api/views/core.py @@ -83,7 +83,7 @@ class RegionViewSet( class NGAViewSet(MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet): """ - A viewset for viewing and editing NGA. + A viewset for viewing and editing NGAs, Natural Geographic Areas. """ model = Nga From 9312f8469923b739cfbaed8ef54bd9146457c384 Mon Sep 17 00:00:00 2001 From: Kalle Westerling <7298727+kallewesterling@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:16:32 +0200 Subject: [PATCH 15/16] Fixing the breaking of logo (see comment by @edwardchalstrey1) --- seshat/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/settings/base.py b/seshat/settings/base.py index d148a3cbb..6dfb40b9c 100644 --- a/seshat/settings/base.py +++ b/seshat/settings/base.py @@ -340,7 +340,7 @@ # but let's keep things as it is for the moment # I believe this says: anything under the base directory that is inside a directory called 'static' will be collected as statidfile, # regardless of how deep down in the directory hierarchy it might be. It just needs to be a in a older called media in any of the apps, etc. -STATICFILES_DIRS = [BASE_DIR / "static"] +STATICFILES_DIRS = [BASE_DIR / "static", BASE_DIR / "staticfiles"] """ Defines the directories in which Django will search for additional static files. """ From 235dd62133bb673ace942110d172f893a6ef53bf Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 10 Jul 2024 11:49:23 +0100 Subject: [PATCH 16/16] revert change to STATICFILES_DIRS and django_heroku --- seshat/settings/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seshat/settings/base.py b/seshat/settings/base.py index 6dfb40b9c..800034b70 100644 --- a/seshat/settings/base.py +++ b/seshat/settings/base.py @@ -11,10 +11,11 @@ import os -# import django_heroku +import django_heroku # import dj_database_url from decouple import config +# from decouple import Csv import sys from django.contrib.messages import constants as messages @@ -340,7 +341,7 @@ # but let's keep things as it is for the moment # I believe this says: anything under the base directory that is inside a directory called 'static' will be collected as statidfile, # regardless of how deep down in the directory hierarchy it might be. It just needs to be a in a older called media in any of the apps, etc. -STATICFILES_DIRS = [BASE_DIR / "static", BASE_DIR / "staticfiles"] +STATICFILES_DIRS = [BASE_DIR / "static"] """ Defines the directories in which Django will search for additional static files. """ @@ -433,7 +434,7 @@ #LOGOUT_REDIRECT_URL = 'logout' # I believe this says: Hey Heroku, do your local settings, don't care about my static_root, static_url etc. -# django_heroku.settings(locals()) +django_heroku.settings(locals()) #print("###################") #print(STATICFILES_DIRS) #print(STATIC_ROOT)