def project_apply(): form = ProjectRegistrationForm(request.form) if request.method == 'POST' and form.validate(): data = dict(request.form) action = str(data['button'][0]) print "Project Data" print data for key in data: if key in [ 'agreement_use', 'agreement_slides', 'agreement_support', 'agreement_software', 'agreement_documentation', 'join_open', 'join_notification' ]: if str(data[key][0]) == 'y': data[key] = True elif str(data[key][0]) == 'n': data[key] = False elif key in [ 'category', 'managers', 'resources_clusters', 'alumni', 'resources_provision', 'resources_services', 'members', 'keywords' ]: print data[key][0] else: data[key] = data[key][0] print str(key) + " - " + str(data[key]) + "\n" del data['button'] if action == 'save': projects = Projects() project = MongoProject() for d in data: project[d] = data[d] print project projects.add(project) flash('Thanks for registering') return redirect('/') project_config = ConfigDict( filename=config_file("/cloudmesh_project_intf.yaml")) project_fields = project_config.get("cloudmesh.project") return render_template('management/project_apply.html', title="Project Application", states=['save', 'cancel'], fields=project_fields, countries_list=[c for c in country_list()], states_list=[c for c in states_list()], disciplines_list=[c for c in disciplines_list()])
def project_apply(): form = ProjectRegistrationForm(request.form) if request.method == 'POST' and form.validate(): data = dict(request.form) action = str(data['button'][0]) for key in data: data[key] = data[key][0] del data['button'] if action == 'save': projects = Projects() project = MongoProject() for d in data: project[d] = data[d] projects.add(project) flash('Thanks for registering') return redirect('/') # return render_template('management/project_apply.html', # title="Project Application", # states=['save', 'cancel'], # form=form, # fields=ProjectRegistrationForm.keys) return render_template('management/project_apply.html', title="Project Application", states=['save', 'cancel'], form=form, fields=ProjectRegistrationForm.keys, profile_fields=ProjectRegistrationForm.profile_keys, vocab_fields=ProjectRegistrationForm.vocab_keys, contact_fields=ProjectRegistrationForm.project_contact_keys, project_details_fields=ProjectRegistrationForm.project_details_keys, agreements_fields=ProjectRegistrationForm.agreements_keys, grant_fields=ProjectRegistrationForm.grant_keys, resource_fields=ProjectRegistrationForm.resource_keys, membership_fields=ProjectRegistrationForm.membership_keys, other_fields=ProjectRegistrationForm.other_keys, loc_fields=ProjectRegistrationForm.loc_keys)
from pprint import pprint from cloudmesh.config.cm_config import get_mongo_db, DBConnFactory # This is not encourged, as importing this file will try to establish a connection get_mongo_db("manage", DBConnFactory.TYPE_MONGOENGINE) # However this file was developed as an executable test/entrance so we leave it like this # alternatively, change this to more Object Oriented way so the connection is # only established when the object is instantiated. # ---------------------------------------------------------- # The generate class generates 10 random users # ---------------------------------------------------------- users = Users() projects = Projects() # http://www.joke2k.net/faker/ fake = Factory.create() def random_user(): ''' returns a random user in a dict :rtype: dict ''' firstname = fake.first_name() data = User( status="pending",