def __init__(self): from users import rank_check from germ.lib import chk ent_table.__init__(self, attributes = [ ('name', string(label.party, perm.all, '', 20, [chk.name])), ('status', choice(label.status, self.opt_status, perm.edit)), ('date', date(label.date, perm.all)), ('organizer', string(label.organizer, perm.all, '', 10)), ('location', string(label.location, perm.all, '', 128)), ('entry_fee_advance', string(label.entry_fee_advance, perm.all, '', 16)), ('entry_fee', string(label.entry_fee, perm.all, '', 16)) ], primary_keys = [ 'name' ], relations = [ relation( table = 'users', keys = { 'organizer': 'username' }, cond = { 'all': "users.rank > 1" }) ], item_txt = { 'edit': { 'en': 'Party Settings', 'de': 'Party Einstellungen' }, 'submit': { 'en': 'Add Party', 'de': 'Party hinzuf"ugen' }, 'view': { 'en': 'View Parties', 'de': 'Partys ansehen' }, 'delete': { 'en': 'Delete Party', 'de': 'Party l"oschen' } }, perm = { 'all': rank_check(self, 1), 'view': True } )
def __init__(self): ent_virtual.__init__(self, attributes = [ ('username', string(label.username, [ 'submit', 'edit' ], '', 10)), (cf.pwd_str + 'old', plain_pwd(label.passwd_old, [ 'edit' ], '', 30)), (cf.pwd_str, plain_pwd(label.passwd, [ 'submit', 'edit' ], '', 30)) ], primary_keys = [ ], action_txt = { 'edit': { 'en': 'change password', 'de': 'Passwort "andern' }, 'submit': { 'en': 'login', 'de': 'einloggen' }, 'delete': { 'en': 'log out', 'de': 'ausloggen' } }, action_report = { 'edit': { 'en': 'The password has been changed', 'de': 'Das Passwort wurde ge"andert' }, 'submit': { 'en': 'You have logged in', 'de': 'Sie wurden eingeloggt' }, 'delete': { 'en': 'You have logged out', 'de': 'Sie wurden ausgeloggt' } })
def __init__(self): from germ.lib.chk import greater_equal ent_table.__init__(self, attributes = [ ('id', sql_id(label.id, perm.edit)), ('username', string(label.username, perm.all, '', 10)), ('date', date(label.date, perm.submit + ['list'])), ('content', text(label.content, perm.all)) ], primary_keys = [ 'id' ], relations = [ relation( table = 'users', keys = { 'username': '******' }, cond = { 'edit': "users.username = $userid OR $users.rank > users.rank", 'submit': "users.username = $userid AND $users.rank > 0", 'delete': "users.username = $userid OR $users.rank > users.rank" }), ], item_txt = { 'edit': { 'en': 'Edit news', 'de': 'News editieren' }, 'submit': { 'en': 'Post news', 'de': 'News erstellen' }, 'delete': { 'en': 'Delete news', 'de': 'News l"oschen' }, 'view': { 'en': 'News' }, 'list': { 'en': 'News' } }, action_txt = { 'submit': { 'en': 'post', 'de': 'erstellen' }, 'delete': { 'en': 'delete', 'de': 'l"oschen' } }, action_report = { 'submit': { 'en': 'The news have been posted', 'de': 'Die News wurden erstellt' }, 'delete': { 'en': 'The news have been deleted', 'de': 'Die News wurden gel"oscht' } })
def __init__(self): self.__prev_attr = (None, None, None) opt_rank = [ { 'en': 'Gamer', 'de': 'Spieler' }, { 'en': 'Assistant', 'de': 'Hilfsorga' }, { 'en': 'Staff', 'de': 'Orga' }, { 'en': 'Admin', 'de': 'Admin' } ] opt_genre = [ { 'en': '-' }, { 'en': 'Action (CS, UT, Q3, ...)' }, { 'en': 'Strategy (C&C, Dune, SC, ...)' }, { 'en': 'Sport (NHL, FIFA, NFS, ...)' }, { 'en': 'Simulation (Comanche 4, ...)' }, { 'en': 'Adventure (Auryns Quest, ...)' } ] opt_privacy = [ { 'en': 'show all', 'de': 'Alles anzeigen' }, { 'en': 'hide name and residence', 'de': 'Name und Wohnort geheimhalten' }, { 'en': 'hide all but username', 'de': 'Nur Benutzernamen anzeigen' } ] perm_privacy1 = { 'view': self.check_privacy1, 'edit': True, 'submit': True } perm_privacy2 = { 'view': self.check_privacy2, 'edit': True, 'submit': True } perm_staff = { 'view': self.check_staff } perm_rank = { 'view': self.check_privacy2, 'edit': self.check_rank } from germ.lib import chk from germ.lib.misc import var_check import cf ent_table.__init__(self, attributes = [ ('username', string(label.username, perm.all, None, 10, [chk.identifier])), (cf.pwd_str, passwd(label.passwd, [ 'submit' ], '', 64)), ('rank', choice(label.rank, opt_rank, perm_rank)), ('privacy', choice(label.privacy, opt_privacy, perm.all)), ('surname', string(label.surname, perm_privacy1, '', 64)), ('forename', string(label.forename, perm_privacy1, '', 64)), ('residence', string(label.residence, perm_privacy1, '', 128)), ('email', string(label.email, perm_privacy2, '', 128)), ('icquin', string(label.icquin, perm_privacy2, '', 16)), ('homepage', string(label.homepage, perm_privacy2, '', 128)), ('genre', choice(label.genre, opt_genre, perm_privacy2)), ('last_activity', date(label.last_activity, perm_staff)) ], primary_keys = [ 'username' ], relations = [ relation( table = 'users', alias = 'u', keys = { 'username': '******' }, cond = { 'edit': # user may only edit other users of lower rank, and he may # only change their rank to one lower than his own; # user may only lower own rank (or leave it) "u.username = $userid OR u.rank < $users.rank" }, outer_join = "LEFT" ) ], item_txt = { 'edit': { 'en': 'My Profile', 'de': 'Mein Profil' }, 'submit': { 'en': 'Register', 'de': 'Registrierung' }, 'view': { 'en': 'Users', 'de': 'Benutzer' } }, action_report = { 'submit': { 'en': 'Your registration has been submitted', 'de': 'Sie wurden registriert' } }, perm = { 'submit': var_check(self, 'userid', None) }, magic_var = { 'rank': self.__rank })
def __init__(self): from germ.lib import chk ent_table.__init__(self, attributes = [ ('party', string(label.party, perm.all, '', 20)), ('tourney', string(label.tourney, perm.all, '', 32)), ('name', string(label.team, perm.all, None, 32, [chk.name])), ('leader', string(label.leader, perm.all, '', 10)) ], primary_keys = [ 'party', 'tourney', 'name' ], relations = [ relation( table = 'tourney', alias = 'tn', keys = { 'party': 'party', 'tourney': 'name' }, # make sure tournament is in preparation phase cond = { 'submit': "tn.phase = 1" } ), # NB: The following three relations depend on each other (The # second one uses the first in its condition string). relation( table = 'gamer', keys = { 'party': 'party', 'leader': 'username' }, cond = { 'submit': "(gamer.username = $userid AND " \ "gamer.paid = TRUE) OR " \ "$users.rank > 0" } ), relation( table = 'team', alias = 'current', keys = { 'party': 'party', 'tourney': 'tourney', 'name': 'name' }, # make sure user is the leader of the team cond = { 'edit': "current.leader = $userid" }, outer_join = "LEFT" ), relation( table = 'team_members', alias = 'tm', keys = { 'party': 'party', 'tourney': 'tourney', 'name': 'team', 'leader': 'username' }, cond = { # make sure leader is a member of the team or the # current leader 'edit': "tm.party IS NOT NULL OR gamer.username = current.leader" }, outer_join = "LEFT" ), relation( table = 'team_members', alias = 'tm2', keys = { 'party': 'party', 'tourney': 'tourney', 'leader': 'username' }, cond = { # make sure user is not a member of another team 'submit': "tm2.party IS NULL" }, outer_join = "LEFT" ), relation( table = 'team', alias = 'lt', keys = { 'party': 'party', 'tourney': 'tourney', 'leader': 'leader' }, # make sure user is not a leader of another team # already cond = { 'submit': "lt.leader IS NULL" }, outer_join = "LEFT" ) ], item_txt = { 'edit': { 'en': 'Team Settings', 'de': 'Teameinstellungen' }, 'submit': { 'en': 'Form New Team', 'de': 'Team bilden' }, 'view': { 'en': 'Teams' }, 'list': { 'en': 'Teams' } } )
def __init__(self): #from users import rank_check #perm_paid = { # 'view': True, # 'edit': rank_check(self, 1) } perm_paid = { 'view': True, 'edit': self.perm_paid } perm_seat = { 'edit': self.perm_seat } from germ.lib import chk ent_table.__init__(self, attributes = [ ('party', string(label.party, perm.all + ['delete'], '', 20)), ('username', string(label.username, perm.all + ['delete'], '', 10)), ('seat', int(label.seat, perm_seat, 0, 8, [chk.greater_equal(0)])), ('paid', bool(label.paid, perm_paid, 0)) ], primary_keys = [ 'party', 'username' ], relations = [ relation( table = 'users', keys = { 'username': '******' }, cond = { 'edit': "users.username = $userid OR " \ "users.rank < $users.rank", #"(users.username = $userid AND " \ # # make sure user has paid # "(gamer.paid = TRUE OR $users.rank > 0)) OR " \ #"users.rank < $users.rank", 'submit': "users.username = $userid OR users.rank < $users.rank", 'delete': # The 'gamer.paid = 0' condition should make sure that the # gamer is not subscribed to any tournaments yet, so that # cancelling the registration does not violate any # dependencies. Cancelling a registration after the gamer # has paid requires special considerations. "(users.username = $userid OR users.rank < $users.rank) " \ "AND gamer.paid = FALSE" }), relation( table = 'party', keys = { 'party': 'name' }, cond = { # party has to be in registration phase or # running phase 'submit': "party.status IN (1, 2)", 'edit': "party.status IN (1, 2)" }), relation( table = 'gamer', alias = 'seats', keys = { 'seat': 'seat' }, cond = { 'edit': "seats.seat IS NULL OR seats.seat = '0'" }, outer_join = "LEFT") ], item_txt = { 'edit': { 'en': 'Joined Parties', 'de': 'Anmeldung' }, 'submit': { 'en': 'Join Party', 'de': 'Anmelden' }, 'delete': { 'en': 'Cancel Party', 'de': 'Abmelden' }, 'view': { 'en': 'Gamers', 'de': 'Spieler' }, 'list': { 'en': 'Gamers', 'de': 'Spieler' } }, action_txt = { 'submit': { 'en': 'register', 'de': 'anmelden' }, 'delete': { 'en': 'unregister', 'de': 'abmelden' } }, action_report = { 'submit': { 'en': 'Your party registration has been submitted', 'de': 'Ihre Anmeldung wurde aufgenommen' }, 'delete': { 'en': 'You have cancelled your party registration', 'de': 'Sie sind abgemeldet' } })
def __init__(self): opt_mode = [ { 'en': 'manual', 'de': 'manuell' }, { 'en': 'single elimination' }, { 'en': 'double elimination' } ] opt_phase = [ # 1 { 'en': 'announced' , 'de': 'angek"undigt' }, # 2 { 'en': 'in preparation', 'de': 'in Vorbereitung' }, # 3 { 'en': 'started', 'de': 'gestartet' }, # 4 { 'en': 'finished', 'de': 'beendet' } ] self.__prev_phase = None self.__next_phase = None self.__teams = None from users import rank_check ent_table.__init__(self, attributes = [ ('name', string(label.tourney, perm.all + ['delete'], None, 32)), ('party', string(label.party, perm.all + ['delete'], '', 20)), ('organizer', string(label.organizer, perm.all, '', 10)), ('mode', choice(label.tourney_mode, opt_mode, perm.all)), ('phase', choice(label.tourney_phase, opt_phase, perm.edit)), ('teamsize', int(label.teamsize, perm.all, 1, 2)) ], primary_keys = [ 'party', 'name' ], relations = [ relation( table = 'tourney', alias = 'tn', keys = { 'party': 'party', 'name': 'name' }, cond = { 'delete': "tn.phase IN (0)", 'edit': "tn.phase IN (0, 1)" }, outer_join = "LEFT" ), relation( table = 'users', alias = 'orga', keys = { 'organizer': 'username' }, cond = { 'all': "orga.rank > 0" } ), relation( table = 'party', keys = { 'party': 'name' }, # party must be on cond = { 'submit': "party.status IN (1, 2)", 'edit': "party.status IN (1, 2)" } ) ], item_txt = { 'edit': { 'en': 'Tourney Settings', 'de': 'Turniereinstellungen' }, 'submit': { 'en': 'New Tourney', 'de': 'Turnier hinzuf"ugen' }, 'view': { 'en': 'Tourneys', 'de': 'Turniere' }, 'list': { 'en': 'Tourneys', 'de': 'Turniere' }, 'delete': { 'en': 'Delete Tourney', 'de': 'Turnier l"oschen' } }, perm = { 'all': rank_check(self, 2), 'view': True, 'list': True } )