Package: terra-opp
Terralego Backend for OPP moduleRequirementsTo handle pictures in templates, please install weasyprint requirement librairieshttps://weasyprint.readthedocs.io/en/stable/install.html#linuxFirst, create a data layer for observatory./manage.pycreate_observatory_layer-nobservatoryThen get the given primary key, for example 10.Settings needed to be setTROPP_OBSERVATORY_LAYER_PK=10# replace by primary key given by commandTROPP_OBSERVATORY_ID=20# set the nationnal id of your observatoryVERSATILEIMAGEFIELD_RENDITION_KEY_SETS={'terra_opp':[('original','url'),('full','thumbnail__1500x1125'),('list','thumbnail__300x225'),('thumbnail','thumbnail__180x120'),('thumbnail_vertical','thumbnail__120x180'),]}AUTH_USER_MODEL='terra_accounts.TerraUser'Media filesIf your project is not using the default django storage, then you must define and set a url fetcher in order to tell weasyprint where to find your media files.An example of url fetcher using media files from S3 storage :fromdjango.confimportsettingsfromterra_opp.renderersimportdjango_url_fetcherdefcustom_url_fetcher(url,*args,**kwargs):scheme='https'ifsettings.AWS_S3_SECURE_URLSelse'http'url_prefix=f"{scheme}://{settings.AWS_S3_CUSTOM_DOMAIN}"ifurl.startswith(url_prefix):url=url.replace(url_prefix,settings.AWS_S3_ENDPOINT_URL+settings.AWS_STORAGE_BUCKET_NAME)returndjango_url_fetcher(url,*args,**kwargs)And then you must refer to this custom url fetcher in your settings. Example if your fetcher is define incustom/fetcher.py:TROPP_URL_FETCHER='custom.fetcher.custom_url_fetcher'To start a dev instanceDefine settings you wants intest_oppdjango project.docker-composeupThen initialize the database:docker-composeexecweb/code/venv/bin/python3/code/src/manage.pymigrateand create the base layer:docker-composeexecweb/code/venv/bin/python3/code/src/manage.pycreate_observatory_layer-nobservatoryYou can now edit your code. A django runserver is launched internally so the
this is an autoreload server.You can access to the api onhttp://localhost:8000/api/TestTo run test suite, just launch:docker-composeexecweb/code/venv/bin/python3/code/src/manage.pytestReleasing a new version# on the master branch# update the file CHANGES.md with your latest changesgitchangelog# Next update the version in the file terra-opp/VERSION.mdechoX.X.X>terra-opp/VERSION.md# Next use git release to create the tag et push your branch & tag to origingitreleasseX.X.XAfter this few steps, you can now go on the github repo to create a new release with the corresponding tag.0.7.2 / 2021-04-30Viewpoints are not removed when a city is deletedCreate a city now correctly capitalize the label0.7.1 / 2021-04-29Change default active status to false for viewpoint0.7.0 / 2021-04-28Fix permissions for theme and city viewsAdd categories to themeAdd theme and city filter0.6.11 / 2021-04-27Fix related file uploadFix picture sort0.6.10/ 2021-04-24Add id to viewpiont sortAdd filter for campaignsAdd search for picturesAdd ordering0.6.9 / 2021-04-22Override create model mixin to capitalize cities label (#68)0.6.8 / 2021-04-20Update translationsAdd change state signal for picture and campaign0.6.7 / 2021-04-19Add city to SimpleViewpoint Serializer0.6.6 / 2021-04-19Enhance viewpoint filters0.6.5 / 2021-04-15Add preview views for viewpoint pdfFix all sheets permissions for nowCampaignZipViewpointPdf: API View to retrieve all the viewpoints pdf of a given campaign0.6.4 / 2021-04-14Add vertical thumbnailNormalize case for cities (#62)Update translationsChange picture identifier from integer to string0.6.3 / 2021-04-12Allowing viewpoint to be filter by pictures identifier0.6.2 / 2021-04-10Use constant stateAdd last_picture_date fieldAdd picture dataAdd auto close featureAdd statsAdd campaign -> picture link0.6.1 / 2021-04-07Add active status to simpleviewpoint serializer0.6.0 / 2021-03-30Enhance campaign viewpoints0.5.6 / 2021-03-30Update readme with release procedure (#55)Add more concistency settings naming and documentationAdd checks for TROPP_OBSERVATORY_ID0.5.5 / 2021-03-30Broken release0.5.4 / 2021-03-29Add active status and endpoint for active viewpoint only0.5.3 / 2021-03-17Add owner_id to picture to be to modify itAdd business identifier for picture0.5.2 / 2021-03-11Add active status on viewpoint0.5.1 / 2021-02-17Add permissions generation on migrate0.5.0 / 2021-02-17Add translationsAdd permissions and checkUpdate installation processEnhance command!! WARNING : BREAKING CHANGES !!You need to adapt your project settings and requirementsUse new django-terra-settings instead of django-terra-utilsSome terra-utils functions are directly integrated0.4.2 / 2020-09-09Taking out city and themes from JSON properties, making it related objects on each viewpoint instanceImproving related document serializer, it does not return the file as base64 anymore but only the access url0.4.1 / 2020-08-26Removing signals and doing all the logic in the related viewsetsAdd possibility to make your own url fetcher :Add TROPP_URL_FETCHER settings and instructionsFix factory boy versionusing django.db.models.JSONField instead of django.contrib.postgres.fields0.4.0 / 2020-07-30Warning ! Breaking changesDue to uniformity of storage usages, you need to use file:// schema in your template to access picturesDeprecate defining observatory layer by name.Now you need to define layer pk instead -> TROPP_OBSERVATORY_LAYER_PK.Existing frontend applications should be fixed by TROPP_OBSERVATORY_LAYER_PK=1fix picture propertyfix prefetched data as list and not querysetfix restframework not listed in setup requirementsFix storage usage and make it working with weasyprint with default and custom storagesadd correct dependencies to handle JPGallow argument set layer name at creationdont block if observatory layer pk not defined, to let ability to create itblock start without defined correct layer settingsadd and improve configuration checkingadd command to create point layer to used as observatoryset defined observatory layer by pk and provide info to frontend to avoid expecting hardcoded pk=1 layer for tilesPK and corresponding endpoints are auto added to /api/settings to send dynamic configuration to frontendStorage bucket is not required anymore.0.3.8 / 2020-06-23Fix default settings0.3.7 / 2020-06-19Support django 3.0add "as_versatile" filter for template usage0.3.6 / 2019-12-19Compatibility with python 3.8, django 3.0 and DRF 3.11Add flake8 for linting0.3.5 / 2019-11-04Fix MEDIA_URL may be empty, breaking url fetcher0.3.4/ 2019-10-10Remove remarks field on Picture0.3.3 / 2019-10-09Fix Manifest to include md files0.3.0 / XXXX-XX-XXFirst standalone releaseExtract from terra-common package to make it a standalone package