Ejemplo n.º 1
0
    def post(self):
        form = AddForm(self.request.POST)

        if form.validate():
            dagkot_type = form.dagkot_type.data
            dagkot_for  = form.dagkot_for.data
            dagkot_msg  = form.dagkot_msg.data
            dagkot_img  = form.dagkot_img.data

            dagkot_candle_type = self.request.get('dagkot_candle_type')
            dagkot_candle_path = self.request.get('dagkot_candle_path')
            dagkot_candle_name = self.request.get('dagkot_candle_name')

            candle = Candle(candle_type=dagkot_candle_type, candle_path=dagkot_candle_path,
                candle_name=dagkot_candle_name)

            candle_key = candle.put()
            if candle_key:
                user = users.get_current_user()
                
                dagkot = Dagkot(dagkot_author=user, dagkot_for=dagkot_for, dagkot_message=dagkot_msg,
                    dagkot_type=dagkot_type, dagkot_candle=candle)
            
                dagkot_key = dagkot.put()
                if dagkot_key:
                    if dagkot_img:
                        self.redirect('/upload/images/%s' % dagkot_key)
                    else:
                        self.redirect('/')
                else:
                    self.redirect('/add/error')
            else:
                self.redirect('/add/error')
        else:
            self.render_html('home/add.html', form=form)
Ejemplo n.º 2
0
	def get(self):
		limit = settings.DAGKOTS_PER_PAGE
		offset = 0
		dagkots = Dagkot.all().order('-dagkot_date').run(offset=offset, limit=limit)

		self.render_html('dagkot/view-all.html',
			dagkots=dagkots, current_page='ALL_DAGKOTS')
Ejemplo n.º 3
0
	def get(self):
		user = users.get_current_user()
		limit = settings.DAGKOTS_PER_PAGE
		offset = 0
		
		dagkots = Dagkot.all().filter('dagkot_author =', user).order('-dagkot_date').run(offset=offset, limit=limit)

		self.render_html('dagkot/view-mine.html',
			dagkots=dagkots, current_page='MY_DAGKOTS')
Ejemplo n.º 4
0
    def get(self):
        dagkots = Dagkot.all()
        offset = 0
        limit = settings.DAGKOTS_PER_PAGE

        user = users.get_current_user()
        if user:
            dagkots = dagkots.filter('dagkot_author =', user).order('-dagkot_date').run(offset=offset, limit=limit)
        else:
			dagkots = dagkots.order('-dagkot_date').run(offset=offset, limit=limit)
        
        self.render_html('home/home.html', dagkots=dagkots)
Ejemplo n.º 5
0
	def _query(self):
		try:
			limit = int(self.request.GET['n'])
		except KeyError:
			limit = settings.DAGKOTS_PER_PAGE

		try:
			offset = int(self.request.GET['o'])

			if offset > 0:
				offset -= 1

			offset *= limit
		except KeyError:
			offset = 0

		user = users.get_current_user()
		if user:
		    dagkots = Dagkot.all().filter('dagkot_author =', user).order('-dagkot_date').run(offset=offset, limit=limit)
		else:
		    dagkots = Dagkot.all().order('-dagkot_date').run(offset=offset, limit=limit)

		self.render_html('home/dagkots.html', dagkots=dagkots)
Ejemplo n.º 6
0
	def _query(self, page):
		limit = settings.DAGKOTS_PER_PAGE

		try:
			offset = int(page)
		except ValueError:
			offset = 0

		if offset > 0:
			offset -= 1

		offset *= limit

		dagkots = Dagkot.all().order('-dagkot_date').run(offset=offset, limit=limit)

		self.render_html('dagkot/view-all-next.html', dagkots=dagkots)
Ejemplo n.º 7
0
	def _query(self, page):
		user = users.get_current_user()
		limit = settings.DAGKOTS_PER_PAGE

		try:
			offset = int(page)
		except ValueError:
			offset = 0

		if offset > 0:
			offset -= 1

		offset *= limit

		dagkots = Dagkot.all().filter('dagkot_author =', user).order('-dagkot_date').run(offset=offset, limit=limit)

		self.render_html('dagkot/view-mine-next.html', dagkots=dagkots)
Ejemplo n.º 8
0
	def get(self, dagkot_key):
		try:
			dagkot = Dagkot.get(dagkot_key)

			if dagkot:
				self.render_html('dagkot/view.html', dagkot=dagkot)
			else:
				message_cont = 'Dagkot does not exist'
				message_type = 'ERROR'

				self.render_html('home/landing.html',
					message_content=message_cont,
					message_type=message_type)
		except BadKeyError as e:
			message_cont = 'Invalid key'
			message_type = 'ERROR'

			self.render_html('home/landing.html',
				message_content=message_cont,
				message_type=message_type)
Ejemplo n.º 9
0
	def post(self, dagkot_key):
		# Generate a new upload URL for every upload request.
		data = {
			'upload_url': blobstore.create_upload_url('/upload/handler/%s' % dagkot_key),
			'status'    : 'FAILED'
		}
		
		dagkot = Dagkot.get(dagkot_key)
		if dagkot:
			uploads = self.get_uploads('file')
			blobkey = str(uploads[0].key())

			dagkot.dagkot_pictures.append(blobkey)

			key = dagkot.put()
			if key:
				data['status'] = 'OK'
			else:
				data['message'] = 'Unable to update the dagkot with the new image.'
		else:
			data['message'] = 'Invalid dagkot key. No dagkot was found.'

		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write(json.dumps(data))