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):
        u = cherrypy.user.name
        up = mt.MongoAdmin("datamaster").db["user_files"].posts

        output = ""

        aggregate = ""

        table = common.getCookie("datamaster_table")

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

        if table:
            tableName = "%s_%s_vars" % (table, cherrypy.user.name)
            posts = mt.MongoAdmin("datamaster").db[tableName].posts

            IVs = posts.find({"var_type": "IV"}).distinct("name")
            DVs = posts.find({"var_type": "DV"}).distinct("name")

            # aggregate, download
            datatable = "%s_%s" % (table, cherrypy.user.name)
            agg_out = common.checkVariables(datatable, ["subject", "trial"])
            if agg_out:
                aggregate = agg_out
                download_raw = agg_out
                multi_sub = agg_out
            else:
                aggregate = self.agg(table)
                download_raw = self.raw(table)
                multi_sub = self.onefile(table)

                # make_prts
            prts_out = common.checkVariables(datatable, ["subject", "trial", "run"])
            if prts_out:
                make_prts = prts_out
            else:
                make_prts = self.make_prts(table)

            if kwargs.has_key("dl"):
                if kwargs["dl"] == "agg":
                    output += self.aggregate(table, kwargs)
                elif kwargs["dl"] == "multi":
                    output += self.get_onefile(table, kwargs)
                else:
                    output += self.get_raw(table, kwargs)
            elif kwargs.has_key("prt_onset"):
                output += self.prts(table, kwargs)

        else:
            aggregate = no_table
            download_raw = no_table
            make_prts = no_table
            multi_sub = no_table

        dl = "<p>"
        fcount = 1
        for row in up.find({"user": u}):
            dl += "File %s : <a href='%s/output/%s'>%s</a><br/>" % (fcount, domain, row["fname"], row["fname"])
            fcount += 1
        dl += "</p>"

        items = [
            ["select table", select_table(download_url, table)],
            ["aggregate", aggregate],
            ["download multi-subject file", multi_sub],
            ["create single subject files", download_raw],
            ["make PRTs", make_prts],
            ["download existing file", dl],
        ]

        output += getAccordion(items, contentID="download-small")

        return getPage(output, "download", "download")
Esempio n. 3
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