Esempio n. 1
0
	def index(self, **kwargs):
		u = cherrypy.user.name

		output = ""

		t = common.getCookie('datamaster_table')

		#select any tables
		if kwargs.has_key('select_table'):
			t = kwargs['select_table']
			common.setCookie('datamaster_table', t)

		if t:
			table = "%s_%s" % (t, u)
			var_table = "%s_%s_vars" % (t, u)	
			sid, trial, IVs, DVs, run, outlier, sids = common.getVariables(table, sids=True)


			posts = mt.MongoAdmin("datamaster").db[var_table].posts

			if kwargs.has_key('set_op'):
				output += self.query(table, kwargs)
			if kwargs.has_key('new_var'):
				output += self.create(table, kwargs)
			if kwargs.has_key('merge_var'):
				output += self.merge(table, kwargs)
			if kwargs.has_key('op-outlier-recurse-field'):
				output += self.outlier(table, kwargs)
	
			keys = posts.find().distinct('name')

			condition = getCondition(var_options=keys, label='If (optional)')
			setter = getSetter(var_options=keys, label='Set (required)')

			modify = getForm(condition + setter, modify_url, legend='transform a variable')

			create = getForm(template.get_def("create_column").render(var_options=keys), modify_url)

			merge = getForm(template.get_def("merge_column").render(var_options=keys), modify_url)

			preview = common.preview(table, kwargs, modify_url)

			outliers = common.outlierReport(mt.MongoAdmin("datamaster").db[table].posts) + getForm(template.get_def("mark_outliers").render(DVs=DVs), modify_url)

		else:
			modify = no_table
			create = no_table
			merge = no_table
			preview = no_table
			outliers = no_table

		items = [['select table', select_table(modify_url, t)], ['create', create], ['merge', merge], ['modify', modify], ['detect outliers', outliers], ['preview', preview]]

		output += getAccordion(items, contentID='modify-small')

		return getPage(output, "modify", "modify")
Esempio n. 2
0
	def index(self, **kwargs):

		cookie = cherrypy.request.cookie

		u = cherrypy.user.name

		#establish a table from the cookie
		table = common.getCookie("datamaster_table")

		#user has selected a table
		if kwargs.has_key('select'):
			table = kwargs['select']
			common.setCookie('datamaster_table', table)

		#user has removed a table
		if kwargs.has_key('remove'):

			p = mt.MongoAdmin("datamaster").db["user_tables"].posts
			t = kwargs['remove']

			#is this the currently active table?
			if table == t:
				common.removeCookie('datamaster_table', table)
				table = None

			mt.MongoAdmin("datamaster").db.drop_collection("%s_%s.posts" % (t, u))
			mt.MongoAdmin("datamaster").db.drop_collection("%s_%s_vars.posts" % (t, u))
			p.remove({'user':u, 'table':t})
			mt.MongoAdmin("datamaster").db["user_ul_files"].posts.remove({'user':u, 'table':t})
			common.activity_log('manage', 'remove table', t, kwargs)

		select_table, remove_table = self.table_choice(table, kwargs)

		#user has selected some variable
		if kwargs.has_key('choose'):
			if kwargs['choose'] == 'vars':
				datatable = "%s_%s" % (table, cherrypy.user.name)
				tableName = "%s_%s_vars" % (table, cherrypy.user.name)
				posts = mt.MongoAdmin("datamaster").db[tableName].posts
				for k in kwargs.keys():
					posts.remove({'name':k})
					posts.update({'name':k}, {'$set':{'var_type':kwargs[k]}}, upsert=True)
				common.activity_log("manage", "choose", table, kwargs)
	
		#if there's an active table
		if table:
			choose_vars = self.chooseVars(table)
			review_vars = common.variableTable("%s_%s" % (table, u))
			preview = common.preview("%s_%s" % (table, u), kwargs, manage_url)

		else:
			choose_vars = no_table
			review_vars = no_table
			preview = no_table							
			
	
		items = [['select table', select_table], ['choose variables', choose_vars], ['review variables', review_vars], ['remove table', remove_table], ['preview', preview]]

		accordion = getAccordion(items, contentID='manage-small')

		output = getPage(accordion, "manage", "manage")

		return output