core_models module

exception InvalidIdentError

Bases: UpdateFailedError

Raised when an ident is not valid for editing.

class UpdateSkjemadata(*, table, skjema=None, ident, identifier_column='refnr', refnr, time_units=None, period=None, column, variable, value, old_value, long, mapping_table='mapping_variabelnavn', mapping_match_column='variabel', mapping_result_column='feltsti')

Bases: BaseModel

Model to centralize logic for updating data.

Parameters:
  • table (str) – Name of the table being updated.

  • skjema (str | None) – Type of Altinn3 RA-skjema to insert on.

  • ident (str) – Identity of unit being updated.

  • identifier_column (str) – Identifying column to refer to for updates. Usually refnr, ident for non-Altinn3 data.

  • refnr (str) – Reference number identifying the row.

  • time_units (str | None) – Time unit.

  • period (str | None) – Time unit period to filter by.

  • column (str) – Column that will be updated.

  • variable (str) – Variable associated with the column. Note, this is identical to column if the table is not in the long format.

  • value (Any) – New value to write.

  • old_value (Any) – Previous value in the database.

  • long (bool) – Whether the database table is in the long format or not.

  • mapping_table (str) – Lookup table mapping a variable’s short name to its long name (feltsti), used by the skjemadata INSERT-fallback. Defaults to “mapping_variabelnavn”.

  • mapping_match_column (str) – Column in mapping_table matched against variable (the short name). Defaults to “variabel”.

  • mapping_result_column (str) – Column in mapping_table returned as the long name. Defaults to “feltsti”.

column: str
ident: str
identifier_column: str
long: bool
mapping_match_column: str
mapping_result_column: str
mapping_table: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

old_value: Any
period: str | None
refnr: str
skjema: str | None
table: str
time_units: str | None
to_alert(long, success, datatype=None)
Parameters:
  • success (bool)

  • datatype (str | None)

update_ibis(long)

Writes edited value to database. Raises FieldUpdateError subclasses on failure.

Return type:

None

value: Any
variable: str
class UpdateSkjemamottak(*, refnr, column, value, on_skjemadata_update=False)

Bases: BaseModel

Class to update editing status in table ‘skjemamottak’ for a refnr, runs after user edits ‘status’. Also runs after skjemadata edits (if on_skjemadata_update = True) for postgreSQL connections:

  • If status currently is ‘Ubehandlet’, it updates the status to ‘Under arbeid’. Other statuses are ignored.

Parameters:
  • refnr (str) – Reference number identifying the row.

  • column (str) – Column that will be updated, usually ‘status’ (str option in new model) or ‘editert’ (boolean in old model).

  • value (str | bool) – New value to write. For new model it includes: Literal[“Ubehandlet”, “Under arbeid”, “Ferdig”].

  • on_skjemadata_update (bool)

column: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

on_skjemadata_update: bool
refnr: str
update_ibis()

Applies the update. Returns True if a row was changed, False if skipped.

Return type:

bool

value: str | bool
class UpdateSkjemamottakAktiv(*, refnr, column='aktiv', value, on_skjemadata_update=False)

Bases: UpdateSkjemamottak

Parameters:
  • refnr (str)

  • column (Literal['aktiv'])

  • value (bool)

  • on_skjemadata_update (bool)

column: Literal['aktiv']
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

value: bool
class UpdateSkjemamottakKommentar(*, refnr, column='kommentar', value, on_skjemadata_update=False)

Bases: UpdateSkjemamottak

Parameters:
  • refnr (str)

  • column (Literal['kommentar'])

  • value (str)

  • on_skjemadata_update (bool)

column: Literal['kommentar']
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

value: str