Skip to content

Commit

Permalink
add create new site group section
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-labri-tipton committed Oct 12, 2023
1 parent 06053c0 commit 1785e0e
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions src/sites_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from get_data import (
create_new_site,
create_new_site_group,
create_user,
get_all_users,
get_all_site_groups,
Expand Down Expand Up @@ -318,7 +319,7 @@ def sites_toolbox_page():

# create a new site
st.markdown(
f'<h1 style="color:#63BCAF;font-size:32px;">{"Create New Site"}</h1>',
f'<h1 style="color:#63BCAF;font-size:32px;">{"Create Site"}</h1>',
unsafe_allow_html=True,
)
with st.expander("Input new site data"):
Expand Down Expand Up @@ -406,7 +407,7 @@ def sites_toolbox_page():

# create a new user
st.markdown(
f'<h1 style="color:#63BCAF;font-size:32px;">{"Create New User"}</h1>',
f'<h1 style="color:#63BCAF;font-size:32px;">{"Create User"}</h1>',
unsafe_allow_html=True,
)

Expand All @@ -419,7 +420,9 @@ def sites_toolbox_page():
unsafe_allow_html=True,
)
email = st.text_input("User Email")
site_group_name = st.selectbox("Select a group", site_groups, key="site_group")
site_group_name = st.selectbox(
"Select a group", site_groups, key="site_group"
)
email_validation = validate_email(email)
# check that site group exists
if st.button(f"Create new user"):
Expand All @@ -434,7 +437,6 @@ def sites_toolbox_page():
unsafe_allow_html=True,
)
else:

user = create_user(
session=session,
email=email,
Expand All @@ -450,4 +452,43 @@ def sites_toolbox_page():

if st.button("Close details"):
st.empty()


# create site group
st.markdown(
f'<h1 style="color:#63BCAF;font-size:32px;">{"Create Site Group"}</h1>',
unsafe_allow_html=True,
)

with st.expander("Input new group data"):
with connection.get_session() as session:
st.markdown(
f'<h1 style="color:#FFD053;font-size:22px;">{"Site Group Information"}</h1>',
unsafe_allow_html=True,
)
new_site_group_name = st.text_input("Enter new site group name")
# check that site group exists
if st.button(f"Create new site group"):
if new_site_group_name == "":
st.markdown(
f'<p style="color:#f07167;font-size:16px;">{"Please enter a valid name for the site group."}</p>',
unsafe_allow_html=True,
)
elif new_site_group_name in site_groups:
st.markdown(
f'<p style="color:#f07167;font-size:16px;">{"This site group already exists."}</p>',
unsafe_allow_html=True,
)
else:
new_site_group = create_new_site_group(
session=session,
site_group_name=new_site_group_name,
)
new_site_group_details = {
"site_group": str(new_site_group.site_group_name),
"site_group_uuid": str(new_site_group.site_group_uuid),
"date_added": (new_site_group.created_utc.strftime("%Y-%m-%d")),
}
st.json(new_site_group_details)

if st.button("Close details"):
st.empty()

0 comments on commit 1785e0e

Please sign in to comment.