Ejemplo n.º 1
0
def get_epithet(name):

    person = Person.objects(name=name).first()

    if person:
        return person.epithet
    else:
        epithets = Epithet.objects().all().values_list('epithet')
        num_of_epithets = Person.objects().count()

        choosen_epithet = epithets[random.randint(0, num_of_epithets)]

        Person(name=name, epithet=choosen_epithet).save()

        return choosen_epithet
Ejemplo n.º 2
0
def promote(request):
	error_msg = u"No POST data sent."	
	if request.method == "POST":
		post = request.POST.copy()
		print "promote ID: "+post['id']
		if post.has_key('id') :
			try:
				iid = post['id']
				ideas = Idea.objects(id=iid)
				print "len: "+str(len(ideas))
				if(len(ideas) >0):
					idea = ideas[0]
					idea.ispromoted = True
					incrementStat('promotions',1)
					people = Person.objects(email=idea.email)
					if people and len(people)>0:
						person = people[0]
						person.timesPromoted = person.timesPromoted +1
						rating = Score.objects(type='promotion')[0].value
						person.currentRating = person.currentRating + rating
						person.save()
					idea.save()
					try:
						t = ThreadClass("Idea Promoted", "Your idea '"+str(idea.title)+"' has been promoted and will now go forward for idea selection, it may or may not be chosen for implementation.",[idea.email])
						t.start()					
					except Exception as inst:
						print 'exception sending email '+str(inst)
						traceback.print_exc()
				return HttpResponseRedirect('/')
			except Exception as inst:
				return HttpResponseServerError('wowza! an error occurred, sorry!</br>'+str(inst))
		else:
			error_msg = u"Insufficient POST data (need 'slug' and 'title'!)"
	return HttpResponseServerError(error_msg)
Ejemplo n.º 3
0
def inventory_update_view():
    if login.current_user.is_anonymous():
        abort()
    # 1 = checkin, 2 = checkout
    status = int(request.form["status"])
    checkout_meta = None
    # provide meta
    if status == InventoryItem.CHECKED_OUT:  # checkout
        dtype = int(request.form["duration_type"])
        duration = request.form["duration"]
        try:
            duration = int(duration)
            # enforce duration limit
            if duration > 999:
                duration = 999
        except ValueError:
            duration = 0
        checkout_meta = CheckoutMeta(
            duration=duration, duration_type=dtype, is_ooo=(True if int(request.form.get("ooo", 0)) else False)
        )
    person = Person.objects(id=request.form["personid"]).get()
    item = InventoryItem.objects(id=request.form["itemid"]).get()
    # add a log
    log = InventoryLog.add_log(
        person=person, item=item, status=int(request.form["status"]), checkout_meta=checkout_meta
    )
    # update the item status
    item.status = status
    item.save()
    response = {
        "duration": {"dateAdded": log.get_date_added(), "description": log.get_checkout_description()},
        "person": {"name": log.person.name},
    }
    return json.dumps(response)
Ejemplo n.º 4
0
def go(request):
	user = request.user
	rating = None
	if user.is_authenticated():
		people = Person.objects(email=request.user.email)
		if people and len(people)>0:
			person = people[0]			
		 	if person:
		 		pratings = Rating.objects().order_by('score')
		 		if pratings and len(pratings)>=0:
		 			for prating in pratings:
		 				if person.currentRating >= prating.score:
		 					rating = prating
		 					break
	
	template_values = {		
		'user' : user,
		'person' : person,
		'rating' : rating,
	}

	path = os.path.join(os.path.dirname(__file__), 'templates/ideas/mystats.html')
	return render_to_response(path, template_values)
Ejemplo n.º 5
0
def getPerson(request):
	people = Person.objects(email=str(request.user.email))
	if people and len(people)>0:
		person = people[0]
		return person
	return None