Esempio 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)
Esempio n. 2
0
def show_profiles():
	def delete_profile(obj_response,object_id):
		"""
		The delete_profile function is called along with passing a 
		correct ObjectId as object_id. 
		
		The corrosponding table row is removed simultaneously
		"""
		tech_exist = profiles.find_one(ObjectId(object_id))
		if not tech_exist:
			org_exist = pros.find_one(ObjectId(object_id))
			if not org_exist:
				obj_response.alert("No such Profile found")
			else:
				pros.remove(ObjectId(object_id))
				#remove folder also
				#print object_id.__str__()
				folder_name = str(object_id.__str__())
				folder_path = os.path.join(app.config['UPLOADED_FILES_DEST'],\
								folder_name)
				#print folder_name
				image_folder_check_delete(folder_path)
				
				
				div_id =  '"#' + object_id + '"'
				return obj_response.script('$('+div_id+').remove();'),\
				obj_response.script("$('#profiledelete').show()")				
		else:
			#remove the profile
			profiles.remove(ObjectId(object_id))
			folder_name = str(object_id.__str__())
			#print folder_name
			folder_path = os.path.join(app.config['UPLOADED_FILES_DEST'],\
							folder_name)
			image_folder_check_delete(folder_path)
			div_id =  '"#' + object_id + '"'
		return obj_response.script('$('+div_id+').remove();'),\
		 obj_response.script("$('#profiledelete').show()")
	
	#request handling
	if g.sijax.is_sijax_request:
		g.sijax.register_callback('delete_this',delete_profile)
		return g.sijax.process_request()
		
	allprofiles = profiles.find()
	professionals = pros.find()
	return render_template('index.html', profiles=allprofiles,\
	 professionals=professionals)
Esempio n. 3
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)