Esempio n. 1
0
	def post(self, brand_requested, action):
		global brand
		analyticsProps = configparsers.loadPropertyFile('analytics')
		gaAccount = analyticsProps.get('GA', 'ga_account')
		if brand_requested is not None and brand_requested != '':
			
			user = self.request.POST.get('session')

			if utils.validate_brand(brand_requested):
				viewState = 'start'
				brand = brand_requested
				section_content = utils.create_section_content(brand)
				session_key = None
				app_version = os.environ['CURRENT_VERSION_ID']

				brandProps = configparsers.loadPropertyFile('brand')
				brandDisplayName = brandProps.get(brand, 'display_name')
			
				self.context['sessionKey']=session_key
				self.context['sections']=section_content
				self.context['viewState']=viewState
				self.context['brand']=brand
				self.context['user']=user
				self.context['brandDisplayName']=brandDisplayName
				self.context['ga_account']=gaAccount
				template = 'index'
				self.render(template)
			else:
				self.error(500)
		else:
			self.error(500)
Esempio n. 2
0
	def get(self):
		try:
			brandProps = configparsers.loadPropertyFile('brand')
			brand = 'razorfish'
			brandDisplayName = brandProps.get(brand, 'display_name')
			adminUser = users.get_current_user()
			brands = utils.get_brands()
			userData = dict()
			userData['email'] = adminUser.email()
			userData['nickname'] = adminUser.nickname()
			userData['id'] = adminUser.user_id()
			sections = None
			since = None
			sectionContent = utils.create_section_content(brand)
			date = None
			section = self.request.get("section")
			since = self.request.get("since")
			requestedBrand = self.request.get('brand')
			dateQuery = None
			today = datetime.date.today()

			
			
			if since is not "":
				if since == "yesterday":
					delta = datetime.timedelta(days=-1)
					dateQuery = today + delta
				elif since == "lastweek":
					delta = datetime.timedelta(days=-7)
					dateQuery = today + delta
				elif since == "lastmonth":
					delta = datetime.timedelta(days=-30)
					dateQuery = today + delta	
				#sections = actions.action_get_survey_by_date_and_brand(dateQuery, requestedBrand)
				sections = actions.action_get_survey_sections_by_brand(requestedBrand)
				
			self.context['adminUser']=userData
			self.context['brandDisplayName']=brandDisplayName
			self.context['brand']=brand
			self.context['brands']=brands
			self.context['requestedBrand']=requestedBrand
			self.context['requestedSection']=section
			self.context['sectionContent']=sectionContent
			self.context['chartApiSubDomainList']=chartApiSubDomainList
			self.context['sections']=sections
			self.context['since']=since
			template = 'admin'
			self.render(template)

		except Exception, e:
			logging.exception(e)
Esempio n. 3
0
	def get(self, brand_requested, user_id_requested):
		global brand
		analyticsProps = configparsers.loadPropertyFile('analytics')
		gaAccount = analyticsProps.get('GA', 'ga_account')
		brandProps = configparsers.loadPropertyFile('brand')
		home_content = utils.get_home_content(brandProps)
		if brand_requested is not None and brand_requested != '' and user_id_requested is not None and user_id_requested != '' and brandProps.has_section(brand_requested):
			brand = brand_requested
			brandDisplayName = brandProps.get(brand, 'display_name')
			section_content = utils.create_section_content(brand)
			session_key = None
			
			if utils.validate_client_user(brand_requested, user_id_requested) and utils.validate_brand(brand_requested):
				viewState = 'new'
				self.context['home_content']=home_content
				self.context['sessionKey']=session_key
				self.context['sections']=section_content
				self.context['viewState']=viewState
				self.context['brand']=brand
				self.context['user']=user_id_requested
				self.context['brandDisplayName']=brandDisplayName
				self.context['ga_account']=gaAccount
				template = 'index'
				self.render(template)
			else:
				logging.warning('No valid Brand or User found')
				viewState = 'error-404'
				self.context['viewState']=viewState
				self.context['brand']=brand
				self.context['user']=user_id_requested
				self.context['brandDisplayName']=brandDisplayName
				self.context['ga_account']=gaAccount
				template = 'error'
				self.response.set_status(404)
				self.render(template)

		else:
			viewState = 'error-404'
			self.context['viewState']=viewState
			self.context['brand']='razorfish'
			self.context['brandDisplayName']='Razorfish'
			self.context['ga_account']=gaAccount
			template = 'error'
			self.response.set_status(404)
			self.render(template)
Esempio n. 4
0
	def post(self):
		surveyKey = None
		arguments = dict()
		analyticsProps = configparsers.loadPropertyFile('analytics')
		gaAccount = analyticsProps.get('GA', 'ga_account')
		brand_requested = self.request.POST.get('brand')
		user_id = self.request.POST.get('session')
		try:
			brandProps = configparsers.loadPropertyFile('brand')
			
			
			
			if brand_requested is not None and brand_requested != '':
				brand_requested = brand_requested

				
				for arg in self.request.arguments():
					arguments[str(arg)] = self.request.get(arg)

				surveyKey = datastore.set_all_arguments(user_id, brand_requested, arguments)
				
				self.redirect('/'+brand_requested+'/success')

		except (CapabilityDisabledError,BadValueError,ValueError), e:
			logging.error("SurveySubmitHandler() : Error saving data")
			logging.error(e)
			sectionContent = utils.create_section_content(brand_requested)
			# If a Survey has failed to be stored in the datastore we won't receive the surveyKey,
			#  so we need to send the Form arguments to the Mail service
			mailservice.announce_survey_error(arguments)
			# [ST]TODO: We need to have stored the User's answer data, to return the form to the current state
			userAnswers = dict()
			viewState = 'error-500'
			brandDisplayName = brandProps.get(brand_requested, 'display_name')
			self.context['viewState']=viewState
			self.context['brand']=brand_requested
			self.context['brandDisplayName']=brandDisplayName
			self.context['ga_account']=gaAccount
			template = 'error'
			self.response.set_status(500)
			self.render(template)