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) 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/models.py b/seshat/apps/seshat_api/models.py index d886d3c57..e69de29bb 100644 --- a/seshat/apps/seshat_api/models.py +++ b/seshat/apps/seshat_api/models.py @@ -1,46 +0,0 @@ -from django.db import models - - -class Album(models.Model): - """ - :private: - :noindex: - - Note: - TODO - - This model is used to store information about an album. - - It does not seem to belong to the codebase. Remove it? - """ - album_name = models.CharField(max_length=100) - artist = models.CharField(max_length=100) - - -class Track(models.Model): - """ - :private: - :noindex: - - Note: - TODO - - This model is used to store information about tracks in an album. - - It does not seem to belong to the codebase. Remove it? - """ - 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: - """ - :noindex: - """ - unique_together = ['album', 'order'] - ordering = ['order'] - - def __str__(self): - return '%d: %s' % (self.order, self.title) diff --git a/seshat/apps/seshat_api/serializers.py b/seshat/apps/seshat_api/serializers.py index 3e814ddab..5d6da7516 100644 --- a/seshat/apps/seshat_api/serializers.py +++ b/seshat/apps/seshat_api/serializers.py @@ -1,311 +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): - """ - The base serializer for the User model. It is used to serialize the User model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = User - fields = ['url', 'username', 'email', 'groups'] +SESHAT_API_DEPTH = 3 +"""Defines the depth of recursive serialization across all models.""" -class GroupSerializer(serializers.HyperlinkedModelSerializer): - """ - The base serializer for the Group model. It is used to serialize the Group model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Group - fields = ['url', 'name'] - -class ReferenceSerializer(serializers.ModelSerializer): - """ - The base serializer for the Reference model. It is used to serialize the Reference model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - 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 GeneralSerializer(serializers.ModelSerializer): """ - The base serializer for the Human_sacrifice model. It is used to serialize the Human_sacrifice model and return the serialized data in the API response. + A serializer for all models across the API. """ class Meta: - """ - :noindex: - """ - model = Human_sacrifice - fields = ['year_from', 'year_to', 'human_sacrifice', 'tag'] - -class External_conflictSerializer(serializers.ModelSerializer): - """ - The base serializer for the External_conflict model. It is used to serialize the External_conflict model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = External_conflict - fields = ['year_from', 'year_to', 'conflict_name', 'tag'] - -class Internal_conflictSerializer(serializers.ModelSerializer): - """ - The base serializer for the Internal_conflict model. It is used to serialize the Internal_conflict model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Internal_conflict - fields = ['year_from', 'year_to', 'conflict', 'expenditure', 'leader', 'casualty', 'tag'] - -class External_conflict_sideSerializer(serializers.ModelSerializer): - """ - The base serializer for the External_conflict_side model. It is used to serialize the External_conflict_side model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = External_conflict_side - fields = ['year_from', 'year_to', 'conflict_id', 'expenditure', 'leader', 'casualty', 'tag'] - -class Agricultural_populationSerializer(serializers.ModelSerializer): - """ - The base serializer for the Agricultural_population model. It is used to serialize the Agricultural_population model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Agricultural_population - fields = ['year_from', 'year_to', 'agricultural_population', 'tag'] - -class Arable_landSerializer(serializers.ModelSerializer): - """ - The base serializer for the Arable_land model. It is used to serialize the Arable_land model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Arable_land - fields = ['year_from', 'year_to', 'arable_land', 'tag'] - -class Arable_land_per_farmerSerializer(serializers.ModelSerializer): - """ - The base serializer for the Arable_land_per_farmer model. It is used to serialize the Arable_land_per_farmer model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Arable_land_per_farmer - fields = ['year_from', 'year_to', 'arable_land_per_farmer', 'tag'] - -class Gross_grain_shared_per_agricultural_populationSerializer(serializers.ModelSerializer): - """ - The base serializer for the Gross_grain_shared_per_agricultural_population model. It is used to serialize the Gross_grain_shared_per_agricultural_population model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Gross_grain_shared_per_agricultural_population - fields = ['year_from', 'year_to', 'gross_grain_shared_per_agricultural_population', 'tag'] - -class Net_grain_shared_per_agricultural_populationSerializer(serializers.ModelSerializer): - """ - The base serializer for the Net_grain_shared_per_agricultural_population model. It is used to serialize the Net_grain_shared_per_agricultural_population model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Net_grain_shared_per_agricultural_population - fields = ['year_from', 'year_to', 'net_grain_shared_per_agricultural_population', 'tag'] - -class SurplusSerializer(serializers.ModelSerializer): - """ - The base serializer for the Surplus model. It is used to serialize the Surplus model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Surplus - fields = ['year_from', 'year_to', 'surplus', 'tag'] - -class Military_expenseSerializer(serializers.ModelSerializer): - """ - The base serializer for the Military_expense model. It is used to serialize the Military_expense model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Military_expense - fields = ['year_from', 'year_to', 'conflict', 'expenditure', 'tag'] - -class Silver_inflowSerializer(serializers.ModelSerializer): - """ - The base serializer for the Silver_inflow model. It is used to serialize the Silver_inflow model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Silver_inflow - fields = ['year_from', 'year_to', 'silver_inflow', 'tag'] - -class Silver_stockSerializer(serializers.ModelSerializer): - """ - The base serializer for the Silver_stock model. It is used to serialize the Silver_stock model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Silver_stock - fields = ['year_from', 'year_to', 'silver_stock', 'tag'] - -class Total_populationSerializer(serializers.ModelSerializer): - """ - The base serializer for the Total_population model. It is used to serialize the Total_population model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Total_population - fields = ['year_from', 'year_to', 'total_population', 'tag'] - -class Gdp_per_capitaSerializer(serializers.ModelSerializer): - """ - The base serializer for the Gdp_per_capita model. It is used to serialize the Gdp_per_capita model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Gdp_per_capita - fields = ['year_from', 'year_to', 'gdp_per_capita', 'tag'] - -class Drought_eventSerializer(serializers.ModelSerializer): - """ - The base serializer for the Drought_event model. It is used to serialize the Drought_event model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Drought_event - fields = ['year_from', 'year_to', 'drought_event', 'tag'] - -class Locust_eventSerializer(serializers.ModelSerializer): - """ - The base serializer for the Locust_event model. It is used to serialize the Locust_event model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Locust_event - fields = ['year_from', 'year_to', 'locust_event', 'tag'] - -class Socioeconomic_turmoil_eventSerializer(serializers.ModelSerializer): - """ - The base serializer for the Socioeconomic_turmoil_event model. It is used to serialize the Socioeconomic_turmoil_event model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Socioeconomic_turmoil_event - fields = ['year_from', 'year_to', 'socioeconomic_turmoil_event', 'tag'] - -class Crop_failure_eventSerializer(serializers.ModelSerializer): - """ - The base serializer for the Crop_failure_event model. It is used to serialize the Crop_failure_event model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Crop_failure_event - fields = ['year_from', 'year_to', 'crop_failure_event', 'tag'] - -class Famine_eventSerializer(serializers.ModelSerializer): - """ - The base serializer for the Famine_event model. It is used to serialize the Famine_event model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Famine_event - fields = ['year_from', 'year_to', 'famine_event', 'tag'] - -class Disease_outbreakSerializer(serializers.ModelSerializer): - """ - The base serializer for the Disease_outbreak model. It is used to serialize the Disease_outbreak model and return the serialized data in the API response. - """ - class Meta: - """ - :noindex: - """ - model = Disease_outbreak - fields = ['year_from', 'year_to', 'longitude', 'latitude', 'elevation', 'sub_category', 'magnitude', 'duration', 'tag'] -class PolitySerializer(serializers.ModelSerializer): - """ - The base serializer for the Polity model. It is used to serialize the Polity model and return the serialized data in the API response. - """ - 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: - """ - :noindex: - """ - 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 diff --git a/seshat/apps/seshat_api/urls.py b/seshat/apps/seshat_api/urls.py index 7b45a68e2..9ec19c3ce 100644 --- a/seshat/apps/seshat_api/urls.py +++ b/seshat/apps/seshat_api/urls.py @@ -1,42 +1,1084 @@ from django.urls import path, include from rest_framework import routers -#from rest_framework.urlpatterns import format_suffix_patterns - -from . import views -# from .views import PolityDetail, PolityList # VarList, VarDetail +# Create router for URLs 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) -#router.register(r'references', views.ReferenceViewSet) +# Register viewsets for "account" app + +from .views.accounts import ( + ProfileViewSet, + SeshatExpertViewSet, + SeshatTaskViewSet, +) + +router.register(r"account/profiles", ProfileViewSet, basename="profile") +router.register( + r"account/seshat-experts", + SeshatExpertViewSet, + basename="seshat-expert", +) +router.register(r"account/seshat-tasks", SeshatTaskViewSet, basename="seshat-task") + + +# 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"core/private-comments", + PrivateCommentsViewSet, + basename="private-comment", +) +router.register( + r"core/private-comments-parts", + PrivateCommentsPartsViewSet, + basename="private-comment-part", +) +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"core/nga-polity-relations", + NGAPolityRelationsViewSet, + basename="nga-polity-relation", +) +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"core/variable-hierarchies", + VariableHierarchyViewSet, + basename="variable-hierarchy", +) +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"core/comment-parts", + SeshatCommentPartViewSet, + basename="seshat-comment-part", +) +router.register( + r"core/comment-parts-through-citations", + ScpThroughCtnViewSet, + basename="comment-part-through-citation", +) +#router.register(r"core/commons", SeshatCommonViewSet, basename="common") +router.register(r"core/religions", ReligionViewSet, basename="religion") +router.register( + r"core/video-shapefiles", + VideoShapefileViewSet, + basename="video-shapefile", +) +router.register( + r"core/gadm-shapefiles", + GADMShapefileViewSet, + basename="gadm-shapefile", +) +router.register( + r"core/gadm-countries", GADMCountriesViewSet, basename="gadm-country" +) +router.register( + r"core/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"crisisdb/us-locations", USLocationViewSet, basename="us-location") +router.register( + r"crisisdb/us-violence-subtypes", + USViolenceSubtypeViewSet, + basename="us-violence-subtype", +) +router.register( + r"crisisdb/us-violence-data-sources", + USViolenceDataSourceViewSet, + basename="us-violence-data-source", +) +router.register(r"crisisdb/us-violences", USViolenceViewSet, basename="us-violence") +router.register( + r"crisisdb/crisis-consequences", + CrisisConsequenceViewSet, + basename="crisis-consequence", +) +router.register( + r"crisisdb/power-transitions", + PowerTransitionViewSet, + basename="power-transition", +) + +router.register( + r"crisisdb/human-sacrifices", + HumanSacrificeViewSet, + basename="human-sacrifice", +) +router.register( + r"crisisdb/external-conflicts", + ExternalConflictViewSet, + basename="external-conflict", +) +router.register( + r"crisisdb/external-conflict-sides", + ExternalConflictSideViewSet, + basename="external-conflict-side", +) +router.register( + r"crisisdb/agricultural-populations", + AgriculturalPopulationViewSet, + basename="agricultural-population", +) +router.register(r"crisisdb/arable-lands", ArableLandViewSet, basename="arable-land") +router.register( + r"crisisdb/arable-land-per-farmer", + ArableLandPerFarmerViewSet, + basename="arable-land-per-farmer", +) +router.register( + r"crisisdb/gross-grain-shared-per-agricultural-populations", + GrossGrainSharedPerAgriculturalPopulationViewSet, + basename="gross-grain-shared-per-agricultural-population", +) +router.register( + r"crisisdb/net-grain-shared-per-agricultural-populations", + NetGrainSharedPerAgriculturalPopulationViewSet, + basename="net-grain-shared-per-agricultural-population", +) +router.register(r"crisisdb/surpluses", SurplusViewSet, basename="surplus") +router.register( + r"crisisdb/military-expenses", + MilitaryExpenseViewSet, + basename="military-expense", +) +router.register( + r"crisisdb/silver-inflows", + SilverInflowViewSet, + basename="silver-inflow", +) +router.register( + r"crisisdb/silver-stocks", + SilverStockViewSet, + basename="silver-stock", +) +router.register( + r"crisisdb/total-populations", + TotalPopulationViewSet, + basename="total-population", +) +router.register( + r"crisisdb/gdp-per-capitas", + GDPPerCapitaViewSet, + basename="gdp-per-capita", +) +router.register( + r"crisisdb/drought-events", + DroughtEventViewSet, + basename="drought-event", +) +router.register( + r"crisisdb/locust-events", + LocustEventViewSet, + basename="locust-event", +) +router.register( + r"crisisdb/socioeconomic-turmoil-events", + SocioeconomicTurmoilEventViewSet, + basename="socioeconomic-turmoil-event", +) +router.register( + r"crisisdb/crop-failure-events", + CropFailureEventViewSet, + basename="crop-failure-event", +) +router.register( + r"crisisdb/famine-events", + FamineEventViewSet, + basename="famine-event", +) +router.register( + r"crisisdb/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"general/polity-research-assistants", + PolityResearchAssistantViewSet, + basename="polity-research-assistant", +) +router.register( + r"general/polity-original-names", + PolityOriginalNameViewSet, + basename="polity-original-name", +) +router.register( + r"general/polity-alternative-names", + PolityAlternativeNameViewSet, + basename="polity-alternative-name", +) +router.register( + r"general/polity-durations", PolityDurationViewSet, basename="polity-duration" +) +router.register( + r"general/polity-peak-years", PolityPeakYearsViewSet, basename="polity-peak-years" +) +router.register( + r"general/polity-degree-of-centralizations", + PolityDegreeOfCentralizationViewSet, + basename="polity-degree-of-centralization", +) +router.register( + r"general/polity-suprapolities", + PolitySuprapolityRelationsViewSet, + basename="polity-suprapolity", +) +router.register( + r"general/polity-utm-timezones", + PolityUTMZoneViewSet, + basename="polity-utm-timezone", +) +router.register( + r"general/polity-capitals", PolityCapitalViewSet, basename="polity-capital" +) +router.register( + r"general/polity-languages", PolityLanguageViewSet, basename="polity-language" +) +router.register( + r"general/polity-linguistic-families", + PolityLinguisticFamilyViewSet, + basename="polity-linguistic-family", +) +router.register( + r"general/polity-language-genuses", + PolityLanguageGenusViewSet, + basename="polity-language-genus", +) +router.register( + r"general/polity-religion-genuses", + PolityReligionGenusViewSet, + basename="polity-religion-genus", +) +router.register( + r"general/polity-religion-families", + PolityReligionFamilyViewSet, + basename="polity-religion-family", +) +router.register( + r"general/polity-religions", PolityReligionViewSet, basename="polity-religion" +) +router.register( + r"general/polity-relationship-to-preceding-entities", + PolityRelationshipToPrecedingEntityViewSet, + basename="polity-relationship-to-preceding-entity", +) +router.register( + r"general/polity-preceding-entities", + PolityPrecedingEntityViewSet, + basename="polity-preceding-entity", +) +router.register( + r"general/polity-succeeding-entities", + PolitySucceedingEntityViewSet, + basename="polity-succeeding-entity", +) +router.register( + r"general/polity-supracultural-entities", + PolitySupraculturalEntityViewSet, + basename="polity-supracultural-entity", +) +router.register( + r"general/polity-scale-of-supracultural-interactions", + PolityScaleOfSupraculturalInteractionViewSet, + basename="polity-scale-of-supracultural-interaction", +) +router.register( + r"general/polity-alternate-religion-genuses", + PolityAlternateReligionGenusViewSet, + basename="polity-alternate-religion-genus", +) +router.register( + r"general/polity-alternate-religion-families", + PolityAlternateReligionFamilyViewSet, + basename="polity-alternate-religion-family", +) +router.register( + r"general/polity-alternate-religions", + PolityAlternateReligionViewSet, + basename="polity-alternate-religion", +) +router.register( + r"general/polity-experts", PolityExpertViewSet, basename="polity-expert" +) +router.register( + r"general/polity-editors", PolityEditorViewSet, basename="polity-editor" +) +router.register( + r"general/polity-religious-traditions", + PolityReligiousTraditionViewSet, + basename="polity-religious-tradition", +) + + +# 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"rt/widespread-religions", + WidespreadReligionViewSet, + basename="widespread-religion", +) +router.register( + r"rt/official-religions", + OfficialReligionViewSet, + basename="official-religion", +) +router.register( + r"rt/elites-religions", ElitesReligionViewSet, basename="elites-religion" +) +router.register( + r"rt/theological-syncretism-of-different-religions", + TheoSyncDifRelViewSet, + basename="theological-syncretism-of-different-religions", +) +router.register( + 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"rt/religious-fragmentations", + ReligiousFragmentationViewSet, + basename="religious-fragmentation", +) +router.register( + r"rt/frequency-of-governmental-violence-against-religious-groups", + GovVioFreqRelGrpViewSet, + basename="frequency-of-governmental-violence-against-religious-groups", +) +router.register( + r"rt/government-restrictions-on-public-worships", + GovResPubWorViewSet, + basename="government-restrictions-on-public-worships", +) +router.register( + r"rt/government-restrictions-on-public-proselytizings", + GovResPubProsViewSet, + basename="government-restrictions-on-public-proselytizings", +) +router.register( + r"rt/government-restrictions-on-conversions", + GovResConvViewSet, + basename="government-restrictions-on-conversions", +) +router.register( + r"rt/government-pressure-to-converts", + GovPressConvViewSet, + basename="government-pressure-to-converts", +) +router.register( + 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"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"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"rt/government-restrictions-on-construction-of-religious-buildings", + GovResConsRelBuilViewSet, + basename="government-restrictions-on-construction-of-religious-buildings", +) +router.register( + r"rt/government-restrictions-on-religious-educations", + GovResRelEduViewSet, + basename="government-restrictions-on-religious-educations", +) +router.register( + r"rt/government-restrictions-on-circulation-of-religious-literatures", + GovResCirRelLitViewSet, + basename="government-restrictions-on-circulation-of-religious-literatures", +) +router.register( + 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"rt/frequency-of-societal-violence-against-religious-groups", + SocVioFreqRelGrpViewSet, + basename="frequency-of-societal-violence-against-religious-groups", +) +router.register( + 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"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 ( + 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, +) + +router.register( + r"sc/research-assistants", RAViewSet, basename="research-assistant" +) +router.register( + r"sc/polity-territories", PolityTerritoryViewSet, basename="polity-territory" +) +router.register( + r"sc/polity-populations", + PolityPopulationViewSet, + basename="polity-population", +) +router.register( + r"sc/population-of-the-largest-settlements", + PopulationOfTheLargestSettlementViewSet, + basename="population-of-the-largest-settlement", +) +router.register( + r"sc/settlement-hierarchies", + SettlementHierarchyViewSet, + basename="settlement-hierarchy", +) +router.register( + r"sc/administrative-levels", + AdministrativeLevelViewSet, + basename="administrative-level", +) +router.register( + r"sc/religious-levels", ReligiousLevelViewSet, basename="religious-level" +) +router.register( + r"sc/military-levels", MilitaryLevelViewSet, basename="military-level" +) +router.register( + r"sc/professional-military-officers", + ProfessionalMilitaryOfficerViewSet, + basename="professional-military-officer", +) +router.register( + r"sc/professional-soldiers", + ProfessionalSoldierViewSet, + basename="professional-soldier", +) +router.register( + r"sc/professional-priesthoods", + ProfessionalPriesthoodViewSet, + basename="professional-priesthood", +) +router.register( + r"sc/full-time-bureaucrats", + FullTimeBureaucratViewSet, + basename="full-time-bureaucrat", +) +router.register( + r"sc/examination-systems", + ExaminationSystemViewSet, + basename="examination-system", +) +router.register( + r"sc/merit-promotions", MeritPromotionViewSet, basename="merit-promotion" +) +router.register( + r"sc/specialized-government-buildings", + SpecializedGovernmentBuildingViewSet, + basename="specialized-government-building", +) +router.register( + r"sc/formal-legal-codes", FormalLegalCodeViewSet, basename="formal-legal-code" +) +router.register(r"sc/judges", JudgeViewSet, basename="judge") +router.register(r"sc/courts", CourtViewSet, basename="court") +router.register( + r"sc/professional-lawyers", + ProfessionalLawyerViewSet, + basename="professional-lawyer", +) +router.register( + r"sc/irrigation-systems", + IrrigationSystemViewSet, + basename="irrigation-system", +) +router.register( + r"sc/drinking-water-supplies", + DrinkingWaterSupplySystemViewSet, + basename="drinking-water-supply-system", +) +router.register(r"sc/markets", MarketViewSet, basename="market") +router.register( + r"sc/food-storage-sites", FoodStorageSiteViewSet, basename="food-storage-site" +) +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"sc/mines-or-quarries", MinesOrQuarryViewSet, basename="mines-or-quarry" +) +router.register( + r"sc/mnemonic-devices", MnemonicDeviceViewSet, basename="mnemonic-device" +) +router.register( + r"sc/nonwritten-records", + NonwrittenRecordViewSet, + basename="nonwritten-record", +) +router.register( + r"sc/written-records", WrittenRecordViewSet, basename="written-record" +) +router.register(r"sc/scripts", ScriptViewSet, basename="script") +router.register( + r"sc/non-phonetic-writings", + NonPhoneticWritingViewSet, + basename="non-phonetic-writing", +) +router.register( + r"sc/phonetic-alphabetic-writings", + PhoneticAlphabeticWritingViewSet, + basename="phonetic-alphabetic-writing", +) +router.register( + r"sc/lists-tables-and-classifications", + ListsTablesAndClassificationViewSet, + basename="lists-tables-and-classifications", +) +router.register(r"sc/calendars", CalendarViewSet, basename="calendar") +router.register(r"sc/sacred-texts", SacredTextViewSet, basename="sacred-text") +router.register( + r"sc/religious-literatures", + ReligiousLiteratureViewSet, + basename="religious-literature", +) +router.register( + r"sc/practical-literatures", + PracticalLiteratureViewSet, + basename="practical-literature", +) +router.register(r"sc/histories", HistoryViewSet, basename="history") +router.register(r"sc/philosophies", PhilosophyViewSet, basename="philosophy") +router.register( + r"sc/scientific-literatures", + ScientificLiteratureViewSet, + basename="scientific-literature", +) +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"sc/precious-metals", PreciousMetalViewSet, basename="precious-metal" +) +router.register(r"sc/foreign-coins", ForeignCoinViewSet, basename="foreign-coin") +router.register( + r"sc/indigenous-coins", IndigenousCoinViewSet, basename="indigenous-coin" +) +router.register( + r"sc/paper-currencies", PaperCurrencyViewSet, basename="paper-currency" +) +router.register(r"sc/couriers", CourierViewSet, basename="courier") +router.register( + r"sc/postal-stations", PostalStationViewSet, basename="postal-station" +) +router.register( + r"sc/general-postal-services", + GeneralPostalServiceViewSet, + basename="general-postal-service", +) +router.register( + r"sc/communal-buildings", + CommunalBuildingViewSet, + basename="communal-building", +) +router.register( + r"sc/utilitarian-public-buildings", + UtilitarianPublicBuildingViewSet, + basename="utilitarian-public-building", +) +router.register( + r"sc/symbolic-buildings", + SymbolicBuildingViewSet, + basename="symbolic-building", +) +router.register( + r"sc/entertainment-buildings", + EntertainmentBuildingViewSet, + basename="entertainment-building", +) +router.register( + r"sc/knowledge-or-information-buildings", + KnowledgeOrInformationBuildingViewSet, + basename="knowledge-or-information-building", +) +router.register( + r"sc/other-utilitarian-public-buildings", + OtherUtilitarianPublicBuildingViewSet, + basename="other-utilitarian-public-building", +) +router.register( + r"sc/special-purpose-sites", + SpecialPurposeSiteViewSet, + basename="special-purpose-site", +) +router.register( + r"sc/ceremonial-sites", CeremonialSiteViewSet, basename="ceremonial-site" +) +router.register(r"sc/burial-sites", BurialSiteViewSet, basename="burial-site") +router.register( + r"sc/trading-emporia", TradingEmporiaViewSet, basename="trading-emporium" +) +router.register(r"sc/enclosures", EnclosureViewSet, basename="enclosure") +router.register( + r"sc/length-measurement-systems", + LengthMeasurementSystemViewSet, + basename="length-measurement-system", +) +router.register( + r"sc/area-measurement-systems", + AreaMeasurementSystemViewSet, + basename="area-measurement-system", +) +router.register( + r"sc/volume-measurement-systems", + VolumeMeasurementSystemViewSet, + basename="volume-measurement-system", +) +router.register( + r"sc/weight-measurement-systems", + WeightMeasurementSystemViewSet, + basename="weight-measurement-system", +) +router.register( + r"sc/time-measurement-systems", + TimeMeasurementSystemViewSet, + basename="time-measurement-system", +) +router.register( + r"sc/geometrical-measurement-systems", + GeometricalMeasurementSystemViewSet, + basename="geometrical-measurement-system", +) +router.register( + r"sc/other-measurement-systems", + OtherMeasurementSystemViewSet, + basename="other-measurement-system", +) +router.register( + r"sc/debt-and-credit-structures", + DebtAndCreditStructureViewSet, + basename="debt-and-credit-structure", +) +router.register( + r"sc/stores-of-wealth", StoreOfWealthViewSet, basename="store-of-wealth" +) +router.register( + r"sc/sources-of-support", SourceOfSupportViewSet, basename="source-of-support" +) +router.register( + r"sc/occupational-complexities", + OccupationalComplexityViewSet, + basename="occupational-complexity", +) +router.register( + r"sc/special-purpose-houses", + SpecialPurposeHouseViewSet, + basename="special-purpose-house", +) +router.register( + r"sc/other-special-purpose-sites", + OtherSpecialPurposeSiteViewSet, + basename="other-special-purpose-site", +) +router.register( + r"sc/largest-communication-distances", + LargestCommunicationDistanceViewSet, + basename="largest-communication-distance", +) +router.register( + r"sc/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"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"wf/composite-bows", CompositeBowViewSet, basename="composite-bow" +) +router.register(r"wf/crossbows", CrossbowViewSet, basename="crossbow") +router.register( + r"wf/tension-siege-engines", + TensionSiegeEngineViewSet, + basename="tension-siege-engine", +) +router.register( + r"wf/sling-siege-engines", + SlingSiegeEngineViewSet, + basename="sling-siege-engine", +) +router.register( + r"wf/gunpowder-siege-artilleries", + GunpowderSiegeArtilleryViewSet, + basename="gunpowder-siege-artillery", +) +router.register( + r"wf/handheld-firearms", HandheldFirearmViewSet, basename="handheld-firearm" +) +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"wf/limb-protections", LimbProtectionViewSet, basename="limb-protection" +) +router.register(r"wf/scaled-armors", ScaledArmorViewSet, basename="scaled-armor") +router.register( + r"wf/laminar-armors", LaminarArmorViewSet, basename="laminar-armor" +) +router.register(r"wf/plate-armors", PlateArmorViewSet, basename="plate-armor") +router.register( + r"wf/small-vessel-canoe-etc", + SmallVesselsCanoesEtcViewSet, + basename="small-vessel-canoe-etc", +) +router.register( + r"wf/merchant-ship-pressed-into-service", + MerchantShipPressedIntoServiceViewSet, + basename="merchant-ship-pressed-into-service", +) +router.register( + r"wf/specialized-military-vessels", + SpecializedMilitaryVesselViewSet, + basename="specialized-military-vessel", +) +router.register( + r"wf/settlement-in-defensive-positions", + SettlementInADefensivePositionViewSet, + basename="settlement-in-defensive-position", +) +router.register( + r"wf/wooden-palisades", WoodenPalisadeViewSet, basename="wooden-palisade" +) +router.register( + r"wf/earth-ramparts", EarthRampartViewSet, basename="earth-rampart" +) +router.register(r"wf/ditches", DitchViewSet, basename="ditch") +router.register(r"wf/moats", MoatViewSet, basename="moat") +router.register( + r"wf/stone-walls-non-mortared", + StoneWallsNonMortaredViewSet, + basename="stone-walls-non-mortared", +) +router.register( + r"wf/stone-walls-mortared", + StoneWallsMortaredViewSet, + basename="stone-walls-mortared", +) +router.register( + r"wf/fortified-camps", FortifiedCampViewSet, basename="fortified-camp" +) +router.register( + r"wf/complex-fortifications", + ComplexFortificationViewSet, + basename="complex-fortification", +) +router.register( + r"wf/modern-fortifications", + ModernFortificationViewSet, + basename="modern-fortification", +) +router.register(r"wf/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')) + path("", include(router.urls)), + path( + "api-auth/", include("rest_framework.urls", namespace="rest_framework") + ), ] +from rest_framework.authtoken import views urlpatterns += [ - path('refs/', views.reference_list), - path('refs//', views.reference_detail), - path('albums/', views.album_list), - path('albums//', views.album_detail), -] -# 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) + path('api-token-auth/', views.obtain_auth_token) +] \ No newline at end of file diff --git a/seshat/apps/seshat_api/views.py b/seshat/apps/seshat_api/views.py deleted file mode 100644 index 6867fefcc..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 - - - -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 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..f9ecc98da --- /dev/null +++ b/seshat/apps/seshat_api/views/_mixins.py @@ -0,0 +1,56 @@ +from rest_framework.pagination import PageNumberPagination +from rest_framework.permissions import IsAuthenticated, AllowAny + +from ..serializers import GeneralSerializer + +STANDARD_API_PERMISSION = { + "HEAD": [AllowAny], + "OPTIONS": [AllowAny], + "GET": [AllowAny], + "POST": [IsAuthenticated], + "PUT": [IsAuthenticated], + "PATCH": [IsAuthenticated], + "DELETE": [IsAuthenticated], +} +"""Defines the standard permission 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_PERMISSION + + 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..a11a37da9 --- /dev/null +++ b/seshat/apps/seshat_api/views/accounts.py @@ -0,0 +1,49 @@ +from rest_framework import viewsets + +from ...accounts.models import Profile, Seshat_Expert, Seshat_Task + +from ._mixins import ( + MixinSeshatAPIAuth, + MixinSeshatAPISerializer, + SeshatAPIPagination, +) +from ._permissions import ONLY_ADMIN_PERMISSIONS + + +class ProfileViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ReadOnlyModelViewSet +): + """ + A viewset for viewing user profiles. + """ + + model = Profile + pagination_class = SeshatAPIPagination + 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 + pagination_class = SeshatAPIPagination + lookup_field = "user__username" + permissions_dict = ONLY_ADMIN_PERMISSIONS + + +class SeshatTaskViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ReadOnlyModelViewSet +): + """ + A viewset for viewing Seshat Tasks. + """ + + model = Seshat_Task + pagination_class = SeshatAPIPagination + 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..50df3a1f6 --- /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 NGAs, Natural Geographic Areas. + """ + + 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..8b95bb4e5 --- /dev/null +++ b/seshat/apps/seshat_api/views/rt.py @@ -0,0 +1,262 @@ +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 Theological Syncretism of Different Religions. + """ + + model = Theo_sync_dif_rel + pagination_class = SeshatAPIPagination + + +class SyncRelPraIndBeliViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +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 Frequency of Governmental Violence Against Religious Groups. + """ + + model = Gov_vio_freq_rel_grp + pagination_class = SeshatAPIPagination + + +class GovResPubWorViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Public Worships. + """ + + model = Gov_res_pub_wor + pagination_class = SeshatAPIPagination + + +class GovResPubProsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Public Proselytizings. + """ + + model = Gov_res_pub_pros + pagination_class = SeshatAPIPagination + + +class GovResConvViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Conversions. + """ + + model = Gov_res_conv + pagination_class = SeshatAPIPagination + + +class GovPressConvViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Pressures to Converts. + """ + + model = Gov_press_conv + pagination_class = SeshatAPIPagination + + +class GovResPropOwnForRelGrpViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +class TaxRelAdhActInsViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +class GovOblRelGrpOfcRecoViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +class GovResConsRelBuilViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Construction of Religious Buildings. + """ + + model = Gov_res_cons_rel_buil + pagination_class = SeshatAPIPagination + + +class GovResRelEduViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Religious Education. + """ + + model = Gov_res_rel_edu + pagination_class = SeshatAPIPagination + + +class GovResCirRelLitViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Government Restrictions on Circulation of Religious Literature. + """ + + model = Gov_res_cir_rel_lit + pagination_class = SeshatAPIPagination + + +class GovDisRelGrpOccFunViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +class SocVioFreqRelGrpViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Social Violence Against Religious Groups. + """ + + model = Soc_vio_freq_rel_grp + pagination_class = SeshatAPIPagination + + +class SocDisRelGrpOccFunViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + 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 + + +class GovPressConvForAgaViewSet( + MixinSeshatAPISerializer, MixinSeshatAPIAuth, viewsets.ModelViewSet +): + """ + A viewset for viewing and editing Societal Pressure to Convert or Against Conversions. + """ + + 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 diff --git a/seshat/settings/base.py b/seshat/settings/base.py index 57ddc91e5..4eebb613a 100644 --- a/seshat/settings/base.py +++ b/seshat/settings/base.py @@ -13,8 +13,9 @@ import django_heroku -import dj_database_url -from decouple import Csv, config +# import dj_database_url +from decouple import config +# from decouple import Csv import sys from django.contrib.messages import constants as messages @@ -87,6 +88,7 @@ 'django.contrib.gis', 'leaflet', #'easyaudit', + 'rest_framework.authtoken' ] AUTHENTICATION_BACKENDS = [ @@ -411,6 +413,10 @@ 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny', ], + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + 'rest_framework.authentication.SessionAuthentication', + ), } """ REST_FRAMEWORK defines the default settings for the Django REST framework.