-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba9f366
commit b4f5b61
Showing
5 changed files
with
116 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<CreateUserScreen>: | ||
BoxLayout: | ||
orientation: 'vertical' | ||
padding: [100, 100, 50, 100] | ||
spacing: 25 | ||
size_hint: None, None | ||
size: root.width, root.height | ||
|
||
Label: | ||
text: "Create New User" | ||
font_size: 24 | ||
size_hint_y: None | ||
height: 30 | ||
|
||
Label: | ||
id: errorMessage | ||
text: "" | ||
color: 1, 0, 0, 1 | ||
opacity: 0 | ||
|
||
BoxLayout: | ||
orientation: 'vertical' | ||
size_hint: None, None | ||
size: 400, 200 | ||
pos_hint: {'center_x': 0.5, 'center_y': 0.5} | ||
padding: [20, 20, 20, 20] | ||
spacing: 10 | ||
|
||
TextInput: | ||
id: registerFirstName | ||
hint_text: "First Name" | ||
size_hint_y: None | ||
height: 40 | ||
padding: [10, 10] | ||
|
||
TextInput: | ||
id: registerLastName | ||
hint_text: "Last Name" | ||
size_hint_y: None | ||
height: 40 | ||
padding: [10, 10] | ||
|
||
TextInput: | ||
id: registerEmployeeID | ||
hint_text: "Employee id, Blipp Card (Optional)" | ||
size_hint_y: None | ||
height: 40 | ||
padding: [10, 10] | ||
|
||
BoxLayout: | ||
orientation: 'horizontal' | ||
size_hint_y: None | ||
height: 40 | ||
spacing: 20 | ||
|
||
Button: | ||
text: "Register" | ||
on_press: root.registerUser() | ||
Button: | ||
text: "Cancel" | ||
on_press: root.cancel() |
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,44 @@ | ||
from kivy.uix.screenmanager import Screen | ||
|
||
from database import addPatron | ||
|
||
|
||
class CreateUserScreen(Screen): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
|
||
def registerUser(self): | ||
"""Handle the registration logic.""" | ||
registerFirstName = self.ids.registerFirstName.text.strip() | ||
registerLastName = self.ids.registerLastName.text.strip() | ||
registerEmployeeID = self.ids.registerEmployeeID.text.strip() | ||
|
||
# Check for empty fields and show error messages | ||
if not registerFirstName: | ||
self.ids.errorMessage.text = "First Name cannot be empty!" | ||
self.ids.errorMessage.opacity = 1 | ||
elif not registerLastName: | ||
self.ids.errorMessage.text = "Last Name cannot be empty!" | ||
self.ids.errorMessage.opacity = 1 | ||
else: | ||
self.ids.errorMessage.opacity = 0 | ||
print(f"Registering user: {registerFirstName} {registerLastName}") | ||
if registerEmployeeID: | ||
print(f"Employee ID: {registerEmployeeID}") | ||
else: | ||
print("No Employee ID provided.") | ||
|
||
addPatron(registerFirstName, registerLastName, registerEmployeeID) | ||
|
||
self.manager.current = "loginScreen" | ||
|
||
def cancel(self): | ||
"""Handle the cancel action.""" | ||
|
||
self.ids.registerFirstName.text = "" | ||
self.ids.registerLastName.text = "" | ||
self.ids.registerEmployeeID.text = "" | ||
self.ids.errorMessage.text = "" | ||
self.ids.errorMessage.opacity = 0 | ||
|
||
self.manager.current = "loginScreen" |
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