Skip to content

Commit

Permalink
added unset admin option
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-trapp-itk committed Oct 25, 2019
1 parent 403659a commit d5e3e42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def is_admin(self, token_id):
else:
return False

def set_as_admin(self, p):
"""tags a player as an admin"""
self.database.execute("UPDATE players SET is_admin=? WHERE id=?", (1, p.id))
def set_admin_status(self, p, status):
"""tags or untags a player as an admin"""
self.database.execute("UPDATE players SET is_admin=? WHERE id=?", (status, p.id))
self.database.commit()

def get_all_players(self):
Expand Down
5 changes: 2 additions & 3 deletions src/gui/KickerUi.kv
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
size_hint: 1, 0.1
on_release: root.hide_player()
Button:
text: "Adminrechte geben"
text: "Adminrechte geben/entfernen"
size_hint: 1, 0.1
on_release: root.admin_player()
Button:
Expand Down Expand Up @@ -483,7 +483,7 @@
on_release: root.on_ok()

<AdminPlayerPopup>:
title: 'Spieler als Admin setzen'
title: 'Spieler als Admin setzen/entfernen'
auto_dismiss: False
enable_ok: True
size_hint: None, None
Expand Down Expand Up @@ -515,7 +515,6 @@
on_text: root.validate_input()
on_text_validate: if root.enable_ok: root.on_ok()
disabled: True
# on_focus: root.on_focus(*args)
BoxLayout:
size_hint_y: 0.1
orientation: 'horizontal'
Expand Down
9 changes: 5 additions & 4 deletions src/gui/kickerapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ def on_interval(self, time_elapsed):
token = rfidReader.getAdminToken()
if token is not None:
if db.is_admin(token):
#print("You are an admin.")
self.display_image = 'gui/check.png'
self.scan_token_label_text = self.scan_token_label_success_text
self.timer.cancel()
Expand All @@ -354,18 +353,20 @@ def on_interval(self, time_elapsed):
self.validate_input()
else:
self.scan_token_label_text = self.scan_token_label_error_text
#print("You are not an admin!")

def on_ok(self):
db.set_as_admin(db.get_player_by_name(self.player_name.text))
player = db.get_player_by_name(self.player_name.text)
if(db.is_admin(player.tokenID)):
db.set_admin_status(player,False)
else:
db.set_admin_status(player,True)
self.admin_list.refresh()
self.dismiss()

def on_dismiss(self):
self.timer.cancel()

def validate_input(self):
#print(self.player_name.text)
if self.player_name.text:
player = db.get_player_by_name(self.player_name.text)
if player is None:
Expand Down

0 comments on commit d5e3e42

Please sign in to comment.