-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
michivonah
committed
May 16, 2023
1 parent
b8a5d4a
commit 16c4861
Showing
5 changed files
with
97 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import datetime | ||
import dbfunctions | ||
import branding | ||
import usermanagement as usr | ||
|
||
branding.loadBranding() | ||
|
||
|
@@ -11,25 +12,29 @@ def createCustomer(custname, mail, phone, address, website, birthdate, notes): | |
|
||
st.write(""" | ||
# Customers | ||
Here you can see all customers: | ||
""") | ||
|
||
customerList, newCustomer = st.tabs(["All customers", "Create new customer"]) | ||
if usr.checkLogin(): | ||
st.write('Here you can see all customers:') | ||
|
||
with customerList: | ||
st.dataframe(dbfunctions.loadTable(f"SELECT * FROM allcustomers"), use_container_width=True) | ||
customerList, newCustomer = st.tabs(["All customers", "Create new customer"]) | ||
|
||
with newCustomer: | ||
with st.container(): | ||
newCustomerName = st.text_input('Customer Name') | ||
newCustomerMail = st.text_input('E-Mail Address', placeholder="[email protected]") | ||
newCustomerPhone = st.text_input('Phone', placeholder="+41791234567") | ||
newCustomerURL = st.text_input('Website', placeholder="https://example.com") | ||
newCustomerAddress = st.text_area('Address', placeholder="Example Street 11\n6003 Lucerne") | ||
newCustomerBirthdate = st.date_input('Birthdate', min_value=datetime.date(1900, 1, 1)) | ||
newCustomerNotes = st.text_area('Notes') | ||
createCustomerBtn = st.button('Create customer') | ||
with customerList: | ||
st.dataframe(dbfunctions.loadTable(f"SELECT * FROM allcustomers"), use_container_width=True) | ||
|
||
if createCustomerBtn: | ||
createCustomer(newCustomerName, newCustomerMail, newCustomerPhone, newCustomerAddress, newCustomerURL, newCustomerBirthdate, newCustomerNotes) | ||
with newCustomer: | ||
with st.container(): | ||
newCustomerName = st.text_input('Customer Name') | ||
newCustomerMail = st.text_input('E-Mail Address', placeholder="[email protected]") | ||
newCustomerPhone = st.text_input('Phone', placeholder="+41791234567") | ||
newCustomerURL = st.text_input('Website', placeholder="https://example.com") | ||
newCustomerAddress = st.text_area('Address', placeholder="Example Street 11\n6003 Lucerne") | ||
newCustomerBirthdate = st.date_input('Birthdate', min_value=datetime.date(1900, 1, 1)) | ||
newCustomerNotes = st.text_area('Notes') | ||
createCustomerBtn = st.button('Create customer') | ||
|
||
if createCustomerBtn: | ||
createCustomer(newCustomerName, newCustomerMail, newCustomerPhone, newCustomerAddress, newCustomerURL, newCustomerBirthdate, newCustomerNotes) | ||
|
||
else: | ||
usr.showError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# User rights management | ||
import streamlit as st | ||
|
||
def checkLogin(): | ||
if 'loginSucceed' not in st.session_state: | ||
st.session_state['loginSucceed'] = False | ||
loginSucceed = st.session_state.loginSucceed | ||
return loginSucceed | ||
|
||
def showError(): | ||
st.write('You are not logged in. Please log in before accessing the settings.') | ||
|
||
""" Example for use in page | ||
import usermanagement as usr | ||
if usr.checkLogin(): | ||
# Code here | ||
else: | ||
usr.showError() | ||
""" |