def login_validate(self): if (c.userid != "false"): redirect(url('/users/login?m=2')) session['logged_in'] = True session.save() if request.method == 'POST': loginform = LoginForm(request.POST) if loginform.is_valid(): userid = authenticate_user(loginform.cleaned_data['email'], \ loginform.cleaned_data['password']) if (userid != "invalid" ): session['userid'] = userid session.save() print session['userid'] c.login = "******" print loginform.cleaned_data['redirect'] if request.POST['redirect']=='null': redirect(url('/')) else: redirect(url(str(loginform.cleaned_data['redirect']))) else: c.login = "******" c.form = LoginForm(request.POST) return render("/users/login.mako") else: c.form = LoginForm(request.POST) return render("/users/login.mako") redirect(url('/'))
def job_table_view(self): user_jobs = meta.Session.query(model.job).all() c.jobs = paginate.Page(user_jobs, items_per_page=10) total_pages = len(user_jobs) / 10 + 1 # jobs = meta.Session.query(model.job) # if (len(user_jobs)!=0): # print "\njobs------\n",jobs.first().jobinfo[1].key, jobs.first().jobinfo[1].value # to check if user visiting this page for the first time and # assign the latest jobs page,page_num tell which page to show page_num = total_pages if ( ("page" in request.params) and request.params["page"].isdigit() and (int(request.params["page"]) <= total_pages) ): page_num = int(request.params["page"]) if "m" in request.params: c.display_message = "Job successfully submitted and your Job ID is " + str(request.params["id"]) c.jobs = paginate.Page(user_jobs, page=page_num, items_per_page=10) c.pagenums = c.jobs.pager() c.pagenumber = page_num return render("/pages/job_table_view.mako")
def job_insert(self): if c.userid == "false": redirect(url("/users/login?cont=cactus&action=cactus_form")) thorns = get_thornlist_job(c.userid) if request.method == "POST": try: paramfile = request.POST["parameterfile"] print "thornfile.filename", paramfile.filename # print 'thornfile.filename', paramfile.file.read() param_exists = True except: param_exists = False data_form = CactusForm(request.POST, thorns=thorns) if data_form.is_valid() and param_exists: # add using job queue jobid = add_job(c.userid) add_allnewjobinfo(data_form.cleaned_data, jobid) add_param(paramfile, jobid) # import pdb; pdb.set_trace() redirect(url("/cactus/job_table_view?m=1&id=" + str(jobid))) else: c.form = data_form c.form.fields["thornlist"].choices = thorns return render("/forms/cactus_form.mako")
def register(self): if (c.userid != "false"): redirect(url('/users/regitser')) c.form = RegisterForm() return render('/users/register.mako')
def cactus_form(self): if c.userid == "false": redirect(url("/users/login?cont=cactus&action=cactus_form")) thorns = get_thornlist_job(c.userid) c.form = CactusForm(thorns=thorns) return render("/forms/cactus_form.mako")
def login(self): #h.flash('Please login') try: action = request.params['action'] controller = request.params['cont'] redirect_url ='/%s/%s'%(controller, action) except: redirect_url = 'null' print redirect_url c.form = LoginForm(redirect=redirect_url) return render('/users/login.mako')
def save_thorn(self): if c.userid == "false": redirect(url("/users/login?cont=cactus&action=save_thorn")) if request.method == "POST": thornfile = request.POST["thornfile"] thornform = ThornForm(request.POST) if thornform.is_valid(): add_thorn(c.userid, thornform.cleaned_data["description"], thornfile) redirect(url("/cactus/thorn_list")) else: c.form = thornform return render("/forms/thorn_form.mako")
def register_post(self): if (c.userid != "false"): redirect(url('/users/register?m=3')) if request.method == 'POST': c.form = RegisterForm(request.POST) if c.form.is_valid(): registration = add_user(c.form.cleaned_data) # check to see if email allready exists if (registration == "emailexists"): c.email = "invalid" mess = "email already exists" return render("/users/register.mako") return render("/users/succ_register.mako") else: c.form = RegisterForm(request.POST) return render("/users/register.mako")
def thorn_list(self): if c.userid == "false": redirect(url("/users/login?cont=cactus&action=thorn_list")) thornlist = get_thornlist(c.userid) total_pages = len(thornlist) / 10 + 1 # jobs = meta.Session.query(model.job) # if (len(user_jobs)!=0): # print "\njobs------\n", jobs.first().jobinfo[1].key,jobs.first().jobinfo[1].value # to check if user visiting this page for the first time and # assign the latest jobs page,page_num tell which page to show page_num = total_pages c.thornlist = paginate.Page(thornlist, page=page_num, items_per_page=10) c.pagenums = c.thornlist.pager() c.pagenumber = page_num return render("/pages/thorn_list.mako")
def upload_thorn(self): if c.userid == "false": redirect(url("/users/login?cont=cactus&action=upload_thorn")) c.form = ThornForm() return render("/forms/thorn_form.mako")
def using_cactus(self): return render("/pages/using_cactus.mako")
def resources(self): return render("/pages/resources.mako")
def index(self): return render("/pages/index.mako")
def contact(self): return render("/pages/contact.mako")
def software(self): return render("/pages/software.mako")
def trac(self): return render("/pages/trac.mako")
def about(self): return render("/pages/about.mako")
def param_list(self): return render("/pages/param_list.mako")