Exemplo n.º 1
0
	def delete(self):
		"""DELETE /accounts: Delete an existing item"""
		# url('account')
		user = meta.Session.query(User).get(int(session['user_id']))
		user.delete()
		session.invalidate()
		session.save()
		redirect(url("main"))
Exemplo n.º 2
0
	def delete(self, id, parent_id=None, format='html'):
		"""DELETE /``REST_Collection``/id: Delete an existing item"""
		item = self._get_from_id(id, parent_id)
		if item is None:
			abort(404, detail='404 Not Found')
		self._delete(item)
		
		if self.FORMAT_NEEDS_REDIRECT[format] is True:
			if parent_id is None:
				redirect(self._py_object.url(self.MULTIPLE))
			else:
				redirect(self._py_object.url(self.MULTIPLE, parent_id=parent_id))
		else:
			abort(200, detail='200 OK')
Exemplo n.º 3
0
	def create(self):
		"""POST /accounts: Create a new item"""
		# url('accounts')
		from columns.config.authorization import INV_PERMISSIONS
		item = User()
		item.name = request.POST.get('name',None)
		item.profile = request.POST.get('profile',None)
		item.type = INV_PERMISSIONS['subscriber']
		if session.get('auth_type',None) == 'facebook':
			item.fb_id = session['oid']
		elif session.get('auth_type',None) == 'twitter':
			item.twitter_id = session['oid']
		elif session.get('auth_type',None) == 'openid':
			item.open_id = session['oid']
		session['user_name'] = item.name
		session['user_type'] = item.type
		session['user_profile'] = item.profile
		session.save()
		item.save(session, app_globals)
		redirect(url("main"))
Exemplo n.º 4
0
	def update(self):
		"""PUT /accounts: Update an existing item"""
		# url('account')
		try:
			item = meta.Session.query(User).get(int(session['user_id']))
			#add any other update stuff
			#item = self.update_from_format(ctrl_obj, item, format, request, session, app_globals, parent_id)
			if session.get('auth_type',None) == 'facebook':
				item.fb_id = session['oid']
			elif session.get('auth_type',None) == 'twitter':
				item.twitter_id = session['oid']
			elif session.get('auth_type',None) == 'openid':
				item.open_id = session['oid']
			item.profile = request.POST.get('profile',u'').strip()
			if item.profile == u'':
				item.profile = None
			#session['user_name'] = item.name
			session['user_profile'] = item.profile
			session.save()
			item.save(session, app_globals)
		except:
			log.error(traceback.format_exc())
			abort(500)
		redirect(url("edit_account"))
Exemplo n.º 5
0
	
	def check_unique_name(self):
		try:
			user_name = request.params.getone("name")
			if User.is_unique(user_name):
				return "Not Taken"
			else:
				return "Already Taken"
		except Exception, ex:
			log.error(traceback.format_exc())
			return "Error"
	
	#def add_link(self):
	#	account_type = request.GET.getone('type')
	#
	def set_name(self):
		try:
			user_name = request.POST.getone("name")
			if User.is_unique(user_name):
				user = meta.Session.query(User).get(int(session['user_id']))
				user.name = session['user_name'] = user_name
				user.save()
				session.save()
		except Exception, ex:
			log.error(traceback.format_exc())
		redirect(url("edit_account"))
	
	#def remove_link(self):
	#	account_type = request.GET.getone('type')
	#
Exemplo n.º 6
0
		except TemplateNotFound, ex:
			self.LOGGER.error(ex)
			abort(415, detail='415 Unsupported Media Type')
	
	def create(self, parent_id=None, format='html'):
		"""POST /``REST_Collection``: Create a new item"""
		try:
			item = self._create(format, parent_id)
		except UnacceptedFormat: 
			abort(415, detail='415 Unsupported Media Type')
		except InvalidForm, ex:
			return ex.value
		
		if self.FORMAT_NEEDS_REDIRECT[format] is True:
			if parent_id is None:
				redirect(self._py_object.url(self.MULTIPLE))
			else:
				redirect(self._py_object.url(self.MULTIPLE, parent_id=parent_id))
		else:
			if parent_id is None:
				abort(201, detail='201 Created', headers={'Location': self._py_object.url(self.SINGLE, id=item.id)})
			else:
				abort(201, detail='201 Created', headers={'Location': self._py_object.url(self.SINGLE, parent_id=parent_id, id=item.id)})
	
	def new(self, parent_id=None, format='html'):
		"""GET /``REST_Collection``/new: Form to create a new item"""
		settings = self._get_settings()
		item = self._new(parent_id, with_defaults=True)
		try:
			extra_vars = {'item':item,'settings':settings,'ctrl_name':self.MULTIPLE}
			#if format == 'ajax':
Exemplo n.º 7
0
	def verify(self):
		redirect(url("login"))
Exemplo n.º 8
0
	def challenge(self):
		redirect(url("login"))
Exemplo n.º 9
0
	def delete(self):
		session.invalidate()
		redirect(url("main"))