Package: shopcloud-django-toolbox
shopcloud-django-toolboxinstall$pipinstallshopcloud-django-toolboxModelsAdd the GID as identifier to all django modelsfromshopcloud_django_toolboximportGIDclassFooBarModel(models.Model,GID):passURL-Signinggenerate or load signed base64  encoded dict containing versioned with expiration date for access-controlUsagesettings.pyDJ_TOOLBOX_SIGNER={'VERSION':"1",}dump values dict:fromshopclouddjango.toolboximportsignersigning_key=signer.dumps({"foo":"bar"},expire_in_hours:12)load values dict:fromshopclouddjango.toolboximportsignerfromdjango.httpimportHttpResponseForbiddendefsome_view(request):sign_str=request.GET.get("sign")is_valid,data=signer.loads(sign_str)ifnotis_valid(request):returnHttpResponseForbidden("Not allowed")data.get("xxx")### … some view logic#alternative for a django Request:fromshopclouddjango.toolboximportsignerfromdjango.httpimportHttpResponseForbiddendefsome_view(request):sign_str=request.GET.get("sign")is_valid,data=signer.loads_from_request(sign_str)ifnotis_valid(request):returnHttpResponseForbidden("Not allowed")data.get("xxx")### … some view logic#Django View Decoratorcheck if GET-parametersignis set and has required keys in data objectsfrom shopcloud_django_toolbox import signer
from shopcloud_django_toolbox.decorators import


@require_toolbox_sign(needed_keys=['key_that_must_exist', 'foo', 'bar'])
def some_view(request):
    is_valid, data = signer.loads_from_request(request)
    #
    ## … some view logic
    #TestingAPI standart testsStandart template for thetests.pyfile in all modules with admin and REST API`sfromshopcloud_django_toolbox.testsimportBaseTestAPIEndpointDocfromshopcloud_django_toolboximportTestAdminTestCasefromshopcloud_django_toolbox.testsimportBaseTestApiAuthorizationfromshopcloud_django_toolboximportSetupClassfromshopcloud_django_toolbox.testsimportRepresentationclassTestDocEntpoint(BaseTestAPIEndpointDoc):pass__classTestRepresentation(utils.Representation):deftest_representation(self):from.importseedsself._test_representations_from_seeds(seeds)classTestAdminPages(TestAdminTestCase):MODULE='url-name'deftest_admin_easylineitem(self):self.run_for_model('url-model-name',is_check_add=False,# deactivate when add function is deactivatedis_check_template=False,# deactivate generic template checkis_check_search=True,# activate searchbar checkis_check_detail=False,# erzeugt ein Model-Object und ruft den Detail-View auf,creation_parameters={},# notwendig für den detailcheck da ein generisches erzeugen von spezeillen Models nicht mgl)classTestApiAuthorization(BaseTestApiAuthorization):app_name="url-module-name"deftest_model_foo(self):self.run_test_endpoint("url-model-name")deftest_model_bar(self):self.run_test_endpoint("url-model-name")classYoutAPITest(SetupClass):deftest_api_endpint(self):client=APIClient()client.login(username=self.username,password=self.pwd)r=client.get('/module/api/endpoint')self.assertEqual(r.status_code,status.HTTP_201_CREATED)EventTo fire events and run tasks in prarallel, need [PROJECT] to receive and run the output from log and call the API.fromshopcloud_django_toolboximportEventclassFooBarModel(models.Model):...defdo_event(self):event=Event(name="de.talk-point.platform/module/model/sync",model=self,)event.add_task(queue="default",url=f"moduke/api/model/{self.id}/action/",json={})event.fire()File Hash Generatinggenerate sha-384 file hash for sri with given filepathfromshopcloud-django-toolboximporthash_for_filehash_for_file("./some-file.txt")deploy# change version Number in setup.py ändern und dann erst releasen# delete build and dist-directory$rm-rfbuilddist
$pip3installwheeltwine
$python3setup.pysdistbdist_wheel
$twineuploaddist/*-username__token__