platzky 0.2.11__py3-none-any.whl → 0.2.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
platzky/config.py CHANGED
@@ -42,6 +42,7 @@ class Config(StrictBaseModel):
42
42
  )
43
43
  debug: bool = Field(default=False, alias="DEBUG")
44
44
  testing: bool = Field(default=False, alias="TESTING")
45
+ feature_flags: t.Optional[dict[str, bool]] = Field(default_factory=dict, alias="FEATURE_FLAGS")
45
46
 
46
47
  @classmethod
47
48
  def model_validate(
platzky/db/db.py CHANGED
@@ -49,7 +49,7 @@ class DB(ABC):
49
49
  pass
50
50
 
51
51
  @abstractmethod
52
- def get_menu_items(self) -> list[MenuItem]:
52
+ def get_menu_items_in_lang(self, lang) -> list[MenuItem]:
53
53
  pass
54
54
 
55
55
  @abstractmethod
@@ -69,9 +69,7 @@ class DB(ABC):
69
69
  pass
70
70
 
71
71
  @abstractmethod
72
- def get_logo_url(
73
- self,
74
- ) -> str: # TODO provide alternative text along with the URL of logo
72
+ def get_logo_url(self) -> str: # TODO provide alternative text along with the URL of logo
75
73
  pass
76
74
 
77
75
  @abstractmethod
platzky/db/graph_ql_db.py CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  from gql import Client, gql
5
5
  from gql.transport.aiohttp import AIOHTTPTransport
6
+ from gql.transport.exceptions import TransportQueryError
6
7
  from pydantic import Field
7
8
 
8
9
  from ..models import Color, Post
@@ -99,18 +100,39 @@ class GraphQL(DB):
99
100
 
100
101
  return [Post.model_validate(_standarize_post(post)) for post in raw_ql_posts]
101
102
 
102
- def get_menu_items(self):
103
- menu_items = gql(
104
- """
105
- query MyQuery {
106
- menuItems(stage: PUBLISHED){
107
- name
108
- url
109
- }
110
- }
111
- """
112
- )
113
- return self.client.execute(menu_items)["menuItems"]
103
+ def get_menu_items_in_lang(self, lang):
104
+ menu_items = []
105
+ try:
106
+ menu_items_with_lang = gql(
107
+ """
108
+ query MyQuery($lang: Lang!) {
109
+ menuItems(where: {language: $lang}, stage: PUBLISHED){
110
+ name
111
+ url
112
+ }
113
+ }
114
+ """
115
+ )
116
+ menu_items = self.client.execute(
117
+ menu_items_with_lang, variable_values={"language": lang}
118
+ )
119
+
120
+ # TODO remove try except block after bumping up version
121
+ # now it's backwards compatible with older versions
122
+ except TransportQueryError:
123
+ menu_items_without_lang = gql(
124
+ """
125
+ query MyQuery {
126
+ menuItems(stage: PUBLISHED){
127
+ name
128
+ url
129
+ }
130
+ }
131
+ """
132
+ )
133
+ menu_items = self.client.execute(menu_items_without_lang)
134
+
135
+ return menu_items["menuItems"]
114
136
 
115
137
  def get_post(self, slug):
116
138
  post = gql(
platzky/db/json_db.py CHANGED
@@ -56,9 +56,11 @@ class Json(DB):
56
56
  page = Post.model_validate(next(list_of_pages))
57
57
  return page
58
58
 
59
- def get_menu_items(self) -> list[MenuItem]:
60
- menu_items_raw = self._get_site_content().get("menu_items", [])
61
- menu_items_list = [MenuItem.model_validate(x) for x in menu_items_raw]
59
+ def get_menu_items_in_lang(self, lang) -> list[MenuItem]:
60
+ menu_items_raw = self._get_site_content().get("menu_items", {})
61
+ items_in_lang = menu_items_raw.get(lang, {})
62
+
63
+ menu_items_list = [MenuItem.model_validate(x) for x in items_in_lang]
62
64
  return menu_items_list
63
65
 
64
66
  def get_posts_by_tag(self, tag, lang):
platzky/platzky.py CHANGED
@@ -107,7 +107,7 @@ def create_engine(config: Config, db) -> Engine:
107
107
  "current_lang_country": country,
108
108
  "current_language": locale,
109
109
  "url_link": url_link,
110
- "menu_items": app.db.get_menu_items(),
110
+ "menu_items": app.db.get_menu_items_in_lang(locale),
111
111
  "logo_url": app.db.get_logo_url(),
112
112
  "favicon_url": app.db.get_favicon_url(),
113
113
  "font": app.db.get_font(),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platzky
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary: Not only blog engine
5
5
  License: MIT
6
6
  Requires-Python: >=3.10,<4.0
@@ -2,18 +2,18 @@ platzky/__init__.py,sha256=cEAqMh-FU8mbfCzFQaWMhKX4lDjoxDiQ9S4hTNsSOMg,160
2
2
  platzky/blog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  platzky/blog/blog.py,sha256=caBUewnwd6QrJDv20m4JDfDDjiVu7hM0AJnoTyCdwM4,3009
4
4
  platzky/blog/comment_form.py,sha256=4lkNJ_S_2DZmJBbz-NPDqahvy2Zz5AGNH2spFeGIop4,513
5
- platzky/config.py,sha256=zJhUEKdnO5YelO2uvcYnW4xc2uW1kU87KdlDpx01CCs,2246
5
+ platzky/config.py,sha256=M3gmZI9yI-ThgmTA4RKsAPcnJwJjcWhXipYzq3hO-Hk,2346
6
6
  platzky/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- platzky/db/db.py,sha256=SayR69Nxs9aGMfYumLyLIH0LVLVmwiQt9WAICq59gng,2709
7
+ platzky/db/db.py,sha256=yVlLqKoKRZiGNaQmRv_8Jjk0aMkHdLgDOhPbxvG_MEs,2708
8
8
  platzky/db/db_loader.py,sha256=CuEiXxhIa4bFMm0vi7ugzm7j3WycilGRKCU6smgIImE,905
9
9
  platzky/db/google_json_db.py,sha256=IgfCER7oJ4I_WD4TjhvFFL0voUj6EfeoaVWdoEcHTdA,1499
10
- platzky/db/graph_ql_db.py,sha256=aIqRxPV-Txr5MY2-qVALby9fHyIvWgvSz2t24M9SNRI,7343
11
- platzky/db/json_db.py,sha256=AtZoTcM6S2ZHo19rxkCi4h4E4INGieZ4W6H5O2iormA,3246
10
+ platzky/db/graph_ql_db.py,sha256=yXVhYCXNexYYo8QYeiUzE05uehdkl0cuuxbLU1hFC-k,8148
11
+ platzky/db/json_db.py,sha256=Iqr2bHxd55-ajosCxXOJsJ7T0TOk45KE7oIrrKo5iSM,3313
12
12
  platzky/db/json_file_db.py,sha256=UQ8TadELmqOzj_tgNfmzhtCkDkMAgcB9vaUy0GQXUY4,1010
13
13
  platzky/locale/en/LC_MESSAGES/messages.po,sha256=WaZGlFAegKRq7CSz69dWKic-mKvQFhVvssvExxNmGaU,1400
14
14
  platzky/locale/pl/LC_MESSAGES/messages.po,sha256=sUPxMKDeEOoZ5UIg94rGxZD06YVWiAMWIby2XE51Hrc,1624
15
15
  platzky/models.py,sha256=-IIlyeLzACeTUpzuzvzJYxtT57E6wRiERoRgXJYMMtY,1502
16
- platzky/platzky.py,sha256=tqCqGp-DCeyLuUcwD8RzyZiZ40SpMtRL_mhvS2xDXnc,4896
16
+ platzky/platzky.py,sha256=h4oeC3B8cxbzv-Ut7iGKvsBmRTmxDKcK-R4PzUTZ-fE,4910
17
17
  platzky/plugin_loader.py,sha256=KYLDSEd_hseAgBuSbikerU_IFx-YmcYK5UwYw7kla2E,1106
18
18
  platzky/plugins/google-tag-manager/entrypoint.py,sha256=Z4npXtmCdrSuUG_ZvFdPhUZg5QcwIPGQWj9Uw9dcm8A,1021
19
19
  platzky/plugins/redirections/entrypoint.py,sha256=yoqHsRLqRALdICs5_UMSREkfEo1Lbsjj9tqEA7dsseg,1555
@@ -32,6 +32,6 @@ platzky/templates/post.html,sha256=GSgjIZsOQKtNx3cEbquSjZ5L4whPnG6MzRyoq9k4B8Q,1
32
32
  platzky/templates/robots.txt,sha256=2_j2tiYtYJnzZUrANiX9pvBxyw5Dp27fR_co18BPEJ0,116
33
33
  platzky/templates/sitemap.xml,sha256=iIJZ91_B5ZuNLCHsRtsGKZlBAXojOTP8kffqKLacgvs,578
34
34
  platzky/www_handler.py,sha256=pF6Rmvem1sdVqHD7z3RLrDuG-CwAqfGCti50_NPsB2w,725
35
- platzky-0.2.11.dist-info/METADATA,sha256=G5cQ81l-5gZqXBX6PiVJXkhvH0AL68V2AC4bHm34Sa8,1643
36
- platzky-0.2.11.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
37
- platzky-0.2.11.dist-info/RECORD,,
35
+ platzky-0.2.13.dist-info/METADATA,sha256=T_KA9bQOEypmy-fFR4sznSTuQA6iQhUuD3cMZdgADts,1643
36
+ platzky-0.2.13.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
37
+ platzky-0.2.13.dist-info/RECORD,,