Beispiel #1
0
	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 } )
Beispiel #2
0
	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 })
Beispiel #3
0
	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 } )