Exemplo n.º 1
0
def add_tech_template():
	"""
	Tech template adding
	"""
	
	if request.method == "POST":
		profile_title = request.form['profilename']
		unique_name = request.form['unique']
		intro = request.form['introduction']
		profile_type = request.form['profiletype']
		dosanddonts = request.form['dos']
		designing = request.form['design']
		material_labour = request.form['materials']
		adv = request.form['advantages']
		tags = request.form.getlist('tags')
		profilelinks = request.form.getlist('profilelink')
		
		#print profile_title, unique_name, profile_type, dosanddonts, designing, material_labour, adv
		
		new_profile = {'title': profile_title,\
		'unique' : unique_name, 'profiletype': profile_type, \
		'Introduction': intro, 'Dos and Donts': dosanddonts,\
		'Design and Construction': designing, \
		'Material and Labour': material_labour, \
		'Advantages and Disadvantages': adv, \
		'Tags' : tags ,\
		'Related Profiles' : profilelinks }
	
	
		checkifAdded = profiles.insert(new_profile)
		current = profiles.find_one(checkifAdded)
		
		if type(checkifAdded) == bson.objectid.ObjectId:
			filename = str(checkifAdded.__str__())
			filepath = os.path.join(app.config['UPLOADED_FILES_DEST'],filename)
			image_folder_check_create(filepath)
			current['imgfolderpath_complete'] = filepath
			filepath_static = filepath.split('/static/')
			current['imgfolderpath_retrieve'] = filepath_static[1]
			profiles.save(current)
		
	typeofprofiles = types.find()
	alltags = profiletags.find()
	
	allprofiles = profiles.find()
	professionals = pros.find()
	
	return render_template('tech_template.html',\
	profiletypes=typeofprofiles,\
	tags=alltags,\
	techs=allprofiles, \
	orgs=professionals)
Exemplo n.º 2
0
def add_case_template():
	"""
	Add a case from the predefined templates
	"""
	if request.method == "POST":
		#background
		bg = request.form['background']
		#stake holders
		sh = request.form['stakeholders']
		#tech specs
		ts = request.form['techspecs']
		#highlights
		hl = request.form['highlights']
		
		new_case = {'Background': bg, 'Stake Holders': sh, 'Technical Specifications': ts, 'Highlights': hl}
		
		checkifAdded = cases.insert(new_case)
		current = cases.find_one(checkifAdded)
		
		if type(checkifAdded) == bson.objectid.ObjectId:
			filename = str(checkifAdded.__str__())
			filepath = os.path.join(app.config['UPLOADED_FILES_DEST'],filename)
			image_folder_check_create(filepath)
			current['imgfolderpath_complete'] = filepath
			filepath_static = filepath.split('/static/')
			current['imgfolderpath_retrieve'] = filepath_static[1]
			profiles.save(current)
			
	typeofprofiles = types.find()
	alltags = profiletags.find()

	allprofiles = profiles.find()
	professionals = pros.find()	
	return render_template('case_template.html', \
	tags=alltags, \
	profiletypes=typeofprofiles,\
	orgs=professionals)
Exemplo n.º 3
0
def add_profile():
	"""
	These functions handle profile adding
	"""
	def newprofile_handler(obj_response,name,unique,_type):
		"""
		name: is the profile title
		unique: is the unique title that will go into the url
		_type: is the type of the profile
		"""
		#for debug
		#print name, unique, _type
		
		#create a profile dict
		profile = {'title':name, 'unique': unique, 'profiletype' : _type }
		
		#add the profile into the profiles
		checkifAdded = profiles.insert(profile)
		current = profiles.find_one(checkifAdded)
		
		if type(checkifAdded) == bson.objectid.ObjectId:
			filename = str(checkifAdded.__str__())
			filepath = os.path.join(app.config['UPLOADED_FILES_DEST'],filename)
			image_folder_check_create(filepath)
			current['imgfolderpath_complete'] = filepath
			filepath_static = filepath.split('/static/')
			current['imgfolderpath_retrieve'] = filepath_static[1]
			profiles.save(current)	
		
		#check if the profile is added
		if checkifAdded:
			return obj_response.script("$('#profileaddsuccess').show()"),\
			obj_response.script('$("#addnewprofileform").reset()')
		else:
			return obj_response.script("$('#profileaddfail').show()")
	
	def newtype_handler(obj_response,profilevalue):
		"""
		This function adds a new profile type into the list to choose from
		
		"""
		#debug
		#print profilevalue
		
		#insert type of profile
		types.insert({'name':profilevalue})
		
		#return obj_response.script('Added a new profile type :' + \
		# profilevalue),\
		# obj_response.script('$("#profileselect").append("<option value=' + \
		# profilevalue + '>' + profilevalue + '</option>")')
		return obj_response.script("$('#addType').modal('toggle')"),\
		obj_response.script("$('#profiletypeaddsuccess').show()"),\
		obj_response.script('$("#profileselect").append("<option value=' +\
		 profilevalue + '>' + profilevalue + '</option>")')
		
			
	if g.sijax.is_sijax_request:
			g.sijax.register_callback('save_profiletype',newtype_handler)
			g.sijax.register_callback('save_newprofile', newprofile_handler)	
			return g.sijax.process_request()
			
	typeofprofiles = types.find()
	return render_template('add.html', profiletypes=typeofprofiles, tech=True)