Ejemplo n.º 1
0
Archivo: party.py Proyecto: drizzd/germ
	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 } )
Ejemplo n.º 2
0
Archivo: news.py Proyecto: drizzd/germ
	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' } })
Ejemplo n.º 3
0
Archivo: users.py Proyecto: drizzd/germ
	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 })