* fix services * Port of PR #6 to branch 0.8.0 (#7) * Switch from JSON to multipart file encoding for file upload File upload is detected when body data contains a value of class FileUpload Remaining JSON is converted to FormData Enitre message is sent as multipart * Switch from JSON to multipart file encoding for file upload (#6) File upload is detected when body data contains a value of class FileUpload Remaining JSON is converted to FormData Enitre message is sent as multipart * fix readme * fix client * Remove "@" chars (#11) * Remove "@" chars that led to empty collectionId, collectionName and expand * Make load method more generic * fix license --------- Co-authored-by: Paulo Coutinho <paulocoutinhox@gmail.com> Co-authored-by: Martin <mahe@quantentunnel.de> Co-authored-by: Eoin Fennessy <85010533+eoinfennessy@users.noreply.github.com>
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from pocketbase.models.utils.base_model import BaseModel
|
|
from pocketbase.models.utils.schema_field import SchemaField
|
|
|
|
|
|
class Collection(BaseModel):
|
|
name: str
|
|
type: str
|
|
schema: list[SchemaField]
|
|
system: bool
|
|
list_rule: str | None
|
|
view_rule: str | None
|
|
create_rule: str | None
|
|
update_rule: str | None
|
|
delete_rule: str | None
|
|
options: dict
|
|
|
|
def load(self, data: dict) -> None:
|
|
super().load(data)
|
|
self.name = data.get("name", "")
|
|
self.system = data.get("system", False)
|
|
self.type = data.get("type", "base")
|
|
self.options = data.get("options", {})
|
|
|
|
# rules
|
|
self.list_rule = data.get("listRule", None)
|
|
self.view_rule = data.get("viewRule", None)
|
|
self.create_rule = data.get("createRule", None)
|
|
self.update_rule = data.get("updateRule", None)
|
|
self.delete_rule = data.get("deleteRule", "")
|
|
|
|
# schema
|
|
schema = data.get("schema", [])
|
|
self.schema = []
|
|
for field in schema:
|
|
self.schema.append(SchemaField(**field))
|
|
|
|
def is_base(self):
|
|
return self.type == "base"
|
|
|
|
def is_auth(self):
|
|
return self.type == "auth"
|
|
|
|
def is_single(self):
|
|
return self.type == "single"
|