Esempio n. 1
0
 def formfield_for_dbfield(self, db_field: Field, request: HttpRequest,
                           **kwargs):
     if db_field.name == "selectielijst_procestype_jaar":
         referentielijst_config = ReferentieLijstConfig.get_solo()
         choices = [(year, str(year))
                    for year in referentielijst_config.allowed_years]
         return ChoiceField(
             label=db_field.verbose_name.capitalize(),
             choices=choices,
             initial=referentielijst_config.default_year,
             required=False,
             help_text=db_field.help_text,
             localize=False,
         )
     if db_field.name == "selectielijst_procestype":
         if "object_id" in request.resolver_match.kwargs:
             obj = ZaakType.objects.get(
                 id=str(request.resolver_match.kwargs["object_id"]))
             procestype_jaar = obj.selectielijst_procestype_jaar
         else:
             referentielijst_config = ReferentieLijstConfig.get_solo()
             procestype_jaar = referentielijst_config.default_year
         return get_procestype_field(db_field, request, procestype_jaar,
                                     **kwargs)
     return super().formfield_for_dbfield(db_field, request, **kwargs)
Esempio n. 2
0
    def setUpTestData(cls):
        cls.user = SuperUserFactory.create()

        # there are TransactionTestCases that truncate the DB, so we need to ensure
        # there are available years
        selectielijst_config = ReferentieLijstConfig.get_solo()
        selectielijst_config.allowed_years = [2017, 2020]
        selectielijst_config.save()
Esempio n. 3
0
    def setUpTestData(cls):
        super().setUpTestData()

        cls.base = ReferentieLijstConfig.get_solo().api_root
        Service.objects.create(
            api_type=APITypes.orc,
            api_root=cls.base,
            label="external selectielijst",
            auth_type=AuthTypes.no_auth,
        )
Esempio n. 4
0
    def formfield_for_dbfield(self, db_field: Field, request: HttpRequest, **kwargs):
        if db_field.name == "selectielijst_procestype_jaar":
            referentielijst_config = ReferentieLijstConfig.get_solo()
            choices = [
                (year, str(year)) for year in referentielijst_config.allowed_years
            ]
            return ChoiceField(
                label=db_field.verbose_name.capitalize(),
                choices=choices,
                initial=referentielijst_config.default_year,
                required=False,
                help_text=db_field.help_text,
                localize=False,
            )
        if db_field.name == "selectielijst_procestype":
            if "object_id" in request.resolver_match.kwargs:
                obj = ZaakType.objects.get(
                    id=str(request.resolver_match.kwargs["object_id"])
                )
                procestype_jaar = obj.selectielijst_procestype_jaar
            else:
                referentielijst_config = ReferentieLijstConfig.get_solo()
                procestype_jaar = referentielijst_config.default_year
            try:
                return get_procestype_field(
                    db_field, request, procestype_jaar, **kwargs
                )
            except AttributeError as e:
                logger.exception(e)

                msg = _(
                    "Something went wrong while fetching procestypen, "
                    "this could be due to an incorrect Selectielijst configuration."
                )
                messages.add_message(
                    request, messages.ERROR, msg, extra_tags="procestypen"
                )

                kwargs["initial"] = _("Selectielijst configuration must be fixed first")
                kwargs["disabled"] = True

        return super().formfield_for_dbfield(db_field, request, **kwargs)
Esempio n. 5
0
 def setUp(self):
     super().setUp()
     config = ReferentieLijstConfig.get_solo()
     Service.objects.create(
         api_type=APITypes.orc,
         api_root=config.api_root,
         client_id="test",
         secret="test",
         user_id="test",
         user_representation="Test",
     )
Esempio n. 6
0
    def setUp(self):
        super().setUp()
        site = Site.objects.get_current()
        site.domain = "testserver"
        site.save()
        self.app.set_user(SuperUserFactory.create())

        conf = ReferentieLijstConfig.get_solo()
        conf.default_year = 2020
        conf.allowed_years = [2020]
        conf.save()
Esempio n. 7
0
 def get_zaaktype_procestype(self, obj):
     # obj is form.instance here
     if not obj.zaaktype_id:
         return _(
             "Please save this Resultaattype first to get proper filtering of selectielijstklasses"
         )
     url = obj.zaaktype.selectielijst_procestype
     if not url:
         return _("Please select a Procestype for the related ZaakType to "
                  "get proper filtering of selectielijstklasses")
     client = ReferentieLijstConfig.get_client()
     procestype = client.retrieve("procestype", url)
     return f"{procestype['nummer']} - {procestype['naam']}"
Esempio n. 8
0
 def get_zaaktype_procestype(self, obj):
     url = obj.zaaktype.selectielijst_procestype
     client = ReferentieLijstConfig.get_client()
     procestype = client.retrieve("procestype", url)
     return f"{procestype['nummer']} - {procestype['naam']}"