Coverage for functions \ flipdare \ generated \ model \ issue \ flag_model.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
20# pragma: no cover
21from __future__ import annotations
22from datetime import datetime
23from google.cloud.firestore_v1.transforms import Sentinel
24from flipdare.core.firestore_field import FirestoreField, OptionalFirestoreField
25from flipdare.util.time_util import FirestoreTime
26from typing import Any, TypedDict, cast, Unpack
27from enum import StrEnum
28from pydantic import Field, ConfigDict, TypeAdapter
29from flipdare.firestore.core.app_base_model import AppBaseModel
30from flipdare.generated.shared.model.issue.issue_progress import IssueProgress
31from flipdare.generated.shared.model.issue.disputed_progress import DisputedProgress
32from flipdare.generated.shared.model.issue.flag_type import FlagType
33from flipdare.generated.shared.model.model_obj_type import ModelObjType
34from flipdare.generated.model.issue.resolution_comment_model import (
35 ResolutionCommentModel,
36 ResolutionCommentDict,
37)
40class FlagKeys(StrEnum):
41 ID = "id"
42 CREATED_AT = "created_at"
43 UPDATED_AT = "updated_at"
44 PROGRESS = "progress"
45 DISPUTED_PROGRESS = "disputed_progress"
46 FLAG_TYPE = "flag_type"
47 FROM_UID = "from_uid"
48 TO_UID = "to_uid"
49 SLUG_CODE = "slug_code"
50 OBJ_ID = "obj_id"
51 OBJ_TYPE = "obj_type"
52 DESCRIPTION = "description"
53 USER_IN_DANGER = "user_in_danger"
54 RESOLVED_AT = "resolved_at"
55 RESTRICTION_ID = "restriction_id"
56 RESOLUTION = "resolution"
57 COMMENT_COUNT = "comment_count"
58 VERSION = "version"
59 PROCESSED = "processed"
60 ERROR_COUNT = "error_count"
61 FLAG_EVALUATED = "flag_evaluated"
62 FLAG_RESTRICTION_APPLIED = "flag_restriction_applied"
63 FLAG_USER_NOTIFIED = "flag_user_notified"
64 FLAG_REMOVED_FROM_SEARCH = "flag_removed_from_search"
67# !! IMPORTANT !!
68# !!
69# !! this should only be used in the database to query.
70# !!
71class FlagInternalKeys(StrEnum):
72 CREATED_AT = "created_at"
73 UPDATED_AT = "updated_at"
74 VERSION = "VERSION"
75 PROCESSED = "INT_P"
76 ERROR_COUNT = "INT_E"
77 FLAG_EVALUATED = "INT_F_E"
78 FLAG_RESTRICTION_APPLIED = "INT_F_AR"
79 FLAG_USER_NOTIFIED = "INT_F_UN"
80 FLAG_REMOVED_FROM_SEARCH = "INT_F_RS"
83class FlagModel(AppBaseModel):
84 """Represents a user-generated flag or report in the system, which can be associated with various objects such as dares, comments, or users."""
86 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
88 id: str | None = Field(None, alias="id")
89 created_at: FirestoreField = Field(
90 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
91 )
92 updated_at: FirestoreField = Field(
93 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
94 )
95 progress: IssueProgress = Field(default=IssueProgress.OPEN)
96 disputed_progress: DisputedProgress | None = None
97 flag_type: FlagType
98 from_uid: str
99 to_uid: str
100 slug_code: str
101 obj_id: str
102 obj_type: ModelObjType
103 description: str
104 user_in_danger: bool = Field(default=False)
105 resolved_at: OptionalFirestoreField = Field(default=None)
106 restriction_id: str | None = None
107 resolution: ResolutionCommentModel | None = None
108 comment_count: int = Field(default=0)
109 # Version (base internal field)
110 version: int = Field(default=1, alias="VERSION")
111 # Processed (base internal field)
112 processed: bool = Field(default=False, alias="INT_P")
113 # Error Count (base internal field)
114 error_count: int = Field(default=0, alias="INT_E")
115 # Flag Evaluated (internal field)
116 flag_evaluated: bool = Field(default=False, alias="INT_F_E")
117 # Flag Restriction Applied (internal field)
118 flag_restriction_applied: bool = Field(default=False, alias="INT_F_AR")
119 # Flag User Notified (internal field)
120 flag_user_notified: bool = Field(default=False, alias="INT_F_UN")
121 # Object Removed from Search (internal field)
122 flag_removed_from_search: bool = Field(default=False, alias="INT_F_RS")
124 @classmethod
125 def validate_partial(cls, **data: Unpack[FlagDict]) -> dict[str, Any]:
126 """
127 Uses Unpack to give you autocomplete and static warnings
128 if you pass an invalid key or type in your code.
130 Returns a dict with Firestore field names (aliases) for use with batch.update().
131 """
132 result: dict[str, Any] = {}
133 for k, v in data.items():
134 if k in cls.__pydantic_fields__:
135 field_info = cls.__pydantic_fields__[k]
136 validated_value = cast(
137 "Any",
138 TypeAdapter(field_info.annotation).validate_python(v),
139 )
140 # Use alias if defined, otherwise use field name
141 output_key = field_info.alias or k
142 result[output_key] = validated_value
143 return result
146FLAG_FIELD_NAMES: list[str] = list(FlagModel.model_fields.keys())
149class FlagDict(TypedDict, total=False):
150 id: str | None
151 created_at: Sentinel | datetime | str
152 updated_at: Sentinel | datetime | str
153 progress: IssueProgress | None
154 disputed_progress: DisputedProgress | None
155 flag_type: FlagType
156 from_uid: str
157 to_uid: str
158 slug_code: str
159 obj_id: str
160 obj_type: ModelObjType
161 description: str
162 user_in_danger: bool | None
163 resolved_at: Sentinel | datetime | str
164 restriction_id: str | None
165 resolution: ResolutionCommentDict | None
166 comment_count: int | None
167 VERSION: int | None
168 INT_P: bool | None
169 INT_E: int | None
170 INT_F_E: bool | None
171 INT_F_AR: bool | None
172 INT_F_UN: bool | None
173 INT_F_RS: bool | None