Skip to content

Commit

Permalink
saving shared state.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeckennedy committed Jun 7, 2020
1 parent 3b05ab8 commit 0e08139
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def update_redirect(redirect_id, name, short_url, url) -> Redirect:
session.close()


def create_page(title: str, url: str, contents: str, creating_user: str) -> Page:
def create_page(title: str, url: str, contents: str, creating_user: str, is_shared: bool) -> Page:
if get_page(url):
raise Exception("Cannot create page, exists!")

Expand All @@ -110,6 +110,7 @@ def create_page(title: str, url: str, contents: str, creating_user: str) -> Page
page.contents = contents.strip()
page.url = url.strip().lower()
page.creating_user = creating_user
page.is_shared = is_shared

session.add(page)
session.commit()
Expand All @@ -120,7 +121,7 @@ def create_page(title: str, url: str, contents: str, creating_user: str) -> Page
session.close()


def update_page(page_id: int, title: str, url: str, contents: str) -> Page:
def update_page(page_id: int, title: str, url: str, contents: str, is_shared: bool) -> Page:
session = db_session.create_session()
try:
page = session.query(Page).filter(Page.id == page_id).first()
Expand All @@ -130,6 +131,7 @@ def update_page(page_id: int, title: str, url: str, contents: str) -> Page:
page.title = title.strip()
page.contents = contents.strip()
page.url = url.strip().lower()
page.is_shared = is_shared

session.commit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def add_page_post():
if not vm.validate():
return vm.to_dict()

cms_service.create_page(vm.title, vm.url, vm.contents, vm.user.email)
cms_service.create_page(vm.title, vm.url, vm.contents, vm.user.email, vm.is_shared)

return flask.redirect('/admin/pages')

Expand All @@ -138,6 +138,6 @@ def edit_page_post(page_id: int):
if not vm.validate():
return vm.to_dict()

cms_service.update_page(vm.page_id, vm.title, vm.url, vm.contents)
cms_service.update_page(vm.page_id, vm.title, vm.url, vm.contents, vm.is_shared)

return flask.redirect('/admin/pages')

0 comments on commit 0e08139

Please sign in to comment.