aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hydrilla/proxy/state.py34
-rw-r--r--src/hydrilla/proxy/state_impl/items.py16
-rw-r--r--src/hydrilla/proxy/web_ui/items.py1
3 files changed, 40 insertions, 11 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py
index 69436c5..1246c92 100644
--- a/src/hydrilla/proxy/state.py
+++ b/src/hydrilla/proxy/state.py
@@ -52,15 +52,37 @@ from .simple_dependency_satisfying import ImpossibleSituation
class EnabledStatus(Enum):
"""
- ENABLED - User wished to always apply given mapping when it matched.
+ ENABLED - User wished to always apply given mapping when it matches site's
+ URL.
DISABLED - User wished to never apply given mapping.
- NO_MARK - User has not configured given mapping and it won't be used.
+ NO_MARK - User has not configured given mapping.
"""
- ENABLED = 'E'
- DISABLED = 'D'
- NO_MARK = 'N'
+ ENABLED = 'E'
+ DISABLED = 'D'
+ NO_MARK = 'N'
+
+
+class FrozenStatus(Enum):
+ """
+ EXACT_VERSION - User wished to always use the same version of a mapping.
+
+ REPOSITORY - User wished to always use a version of the mapping from the
+ same repository.
+
+ NOT_FROZEN - User did not restrict updates of the mapping.
+ """
+ EXACT_VERSION = 'E'
+ REPOSITORY = 'R'
+ NOT_FROZEN = 'N'
+
+ @staticmethod
+ def make(letter: t.Optional[str]) -> t.Optional[FrozenStatus]:
+ if letter is None:
+ return None
+
+ return FrozenStatus(letter)
class InstalledStatus(Enum):
@@ -201,6 +223,7 @@ class MappingDisplayInfo(item_infos.CorrespondsToMappingDCMixin):
ref: 'MappingRef'
identifier: str
enabled: EnabledStatus
+ frozen: t.Optional[FrozenStatus]
active_version: t.Optional['MappingVersionDisplayInfo']
@dc.dataclass(frozen=True)
@@ -212,6 +235,7 @@ class MappingVersionDisplayInfo(item_infos.CorrespondsToMappingDCMixin):
is_orphan: bool
is_local: bool
mapping_enabled: EnabledStatus
+ mapping_frozen: t.Optional[FrozenStatus]
@dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc]
class MappingRef(Ref, item_infos.CorrespondsToMappingDCMixin):
diff --git a/src/hydrilla/proxy/state_impl/items.py b/src/hydrilla/proxy/state_impl/items.py
index b538dc5..ddfef7c 100644
--- a/src/hydrilla/proxy/state_impl/items.py
+++ b/src/hydrilla/proxy/state_impl/items.py
@@ -128,6 +128,7 @@ class ConcreteMappingRef(st.MappingRef):
ive.active,
ive.is_orphan,
ive.is_local,
+ ms.frozen,
ms.enabled
FROM
item_versions_extra AS ive
@@ -147,7 +148,7 @@ class ConcreteMappingRef(st.MappingRef):
for (item_version_id, definition, repo, repo_iteration,
installed_status, active_status, is_orphan, is_local,
- enabled_status) in rows:
+ frozen_status, enabled_status) in rows:
ref = ConcreteMappingVersionRef(str(item_version_id), self.state)
item_info = item_infos.MappingInfo.load(
@@ -163,7 +164,8 @@ class ConcreteMappingRef(st.MappingRef):
active = st.ActiveStatus(active_status),
is_orphan = is_orphan,
is_local = is_local,
- mapping_enabled = st.EnabledStatus(enabled_status)
+ mapping_enabled = st.EnabledStatus(enabled_status),
+ mapping_frozen = st.FrozenStatus.make(frozen_status)
)
result.append(display_info)
@@ -195,7 +197,8 @@ class ConcreteMappingStore(st.MappingStore):
ive.active,
ive.is_orphan,
ive.is_local,
- ms.enabled
+ ms.enabled,
+ ms.frozen
FROM
items AS i
JOIN mapping_statuses AS ms
@@ -213,7 +216,7 @@ class ConcreteMappingStore(st.MappingStore):
for (item_id, identifier, item_version_id, definition, repo,
repo_iteration, installed_status, active_status, is_orphan,
- is_local, enabled_status) in rows:
+ is_local, enabled_status, frozen_status) in rows:
ref = ConcreteMappingRef(str(item_id), self.state)
active_version: t.Optional[st.MappingVersionDisplayInfo] = None
@@ -237,14 +240,15 @@ class ConcreteMappingStore(st.MappingStore):
active = st.ActiveStatus(active_status),
is_orphan = is_orphan,
is_local = is_local,
- mapping_enabled = st.EnabledStatus(enabled_status)
+ mapping_enabled = st.EnabledStatus(enabled_status),
+ mapping_frozen = st.FrozenStatus.make(frozen_status)
)
-
display_info = st.MappingDisplayInfo(
ref = ref,
identifier = identifier,
enabled = st.EnabledStatus(enabled_status),
+ frozen = st.FrozenStatus.make(frozen_status),
active_version = active_version
)
diff --git a/src/hydrilla/proxy/web_ui/items.py b/src/hydrilla/proxy/web_ui/items.py
index c0e0e0d..4bfae0a 100644
--- a/src/hydrilla/proxy/web_ui/items.py
+++ b/src/hydrilla/proxy/web_ui/items.py
@@ -150,6 +150,7 @@ def show_item(item_id: str, item_type: item_infos.ItemType) \
ref = item_ref,
identifier = version_display_infos[0].info.identifier,
enabled = version_display_infos[0].mapping_enabled,
+ frozen = version_display_infos[0].mapping_frozen,
active_version = active_version
)