Beispiel #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)
Beispiel #2
0
def tags():
	"""
	Tags management
	"""
	
	alltags = profiletags.find()
	
	def savetag_handler(obj_response,tagvalue):
		"""
		a handler for a new tag
		"""
		
		
		#obj_response.script('$("#profileselect").append("<option value=' +\
		# profilevalue + '>' + profilevalue + '</option>")')
		
		#<li id="tagvalue4fd8346cbb9348cef0000000"><span class="label label-info">foobar &nbsp;<a style="color: white" href="javascript://" onclick="Sijax.request('deltag', ['4fd8346cbb9348cef0000000']);">x</a></span></li>
		
		backvalue = profiletags.insert({'value': tagvalue})
		#backvalue is actually the ObjectId
		#so we use the ObjectId to retrieve the tag
		
		thetag = profiletags.find_one(backvalue)
		
		return obj_response.script("$('#success').show()"),\
		 obj_response.script("$('#addtagform').reset()")#,\
		 #obj_response.script('$("#taglist").append("<li id=\"tagvalue' + \
		 #thetag['_id'] + '\"<span class="label label-info">' + \
		 #thetag['value'] + \
		 #'<a href="javascript://" onclick="Sijax.request(\'deltag\', [' + \
		 #']);">x</a></span></li>");')
		
	def deltag_handler(obj_response,tagid):
		"""
		a handler for removing existing tags
		"""
		profiletags.remove(ObjectId(tagid))
		tagvalueid = "tagvalue" + tagid
		tagdelid = "tagdeletion" + tagid
		return obj_response.script("$('#"+tagvalueid+"').remove();")
		
	if g.sijax.is_sijax_request:
			g.sijax.register_callback('save_tag',savetag_handler)
			g.sijax.register_callback('deltag',deltag_handler)
			return g.sijax.process_request()	
			
	return render_template('tags.html', alltags=alltags)

################################################################################
Beispiel #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)