Ejemplo n.º 1
0
def updateNote(request):
	if not isDropbear(request.user):
		return render(request, 'error.html', {'title': '403 - Forbidden', 'description': 'You are not a member.'})

	id = request.POST.get('id', False)
	text = request.POST.get('note', False)
	if id and text:		
		try:
			t = Timer.objects.get(id = id)
			t.note = text
			t.save()
		except:
			pass

	return HttpResponse('')
Ejemplo n.º 2
0
def add(request):
	if not isDropbear(request.user):
		return render(request, 'error.html', {'title': '403 - Forbidden', 'description': 'You are not a member.'})

	status = None
	if (request.method == "POST"):
		status = "Something went wrong."

		typeName = request.POST.get("item", None)
		quantity = request.POST.get("quantity", 1)

		try:
			quantity = int(quantity)
		except:
			typeName = False

		if typeName and typeName != "":
			typeID = CCPinvType.objects.filter(typeName=typeName)
			if typeID:
				typeID = typeID.first().typeID
				try:
					c = CorpMarketItem.objects.get(typeID=typeID)
				except:
					c = CorpMarketItem()

				c.typeID = typeID
				c.itemName = typeName
				c.quantity = int(quantity)

				c.save()

				if c.quantity <= 0:
					c.delete()
					status = "Removed <strong>" + typeName + "</strong> from Corp Market List!" 
				else:
					status = "Added <strong>"+ str(quantity) + "x " + typeName + "</strong> to Corp Market List!" 
			else:
				status = "Cannot find "+typeName+" in Database."
		else:
			status = "No item name supplied, or invalid quantity."




	return render(request, "add.html", {"status": status})
Ejemplo n.º 3
0
def list(request):
	if not isDropbear(request.user):
		return render(request, 'error.html', {'title': '403 - Forbidden', 'description': 'You are not a member.'})

	items = CorpMarketItem.objects.all()

	result = []
	chaContents = CorpAsset.objects.filter(parentID__in=settings.STORAGE_CHAS)
	for item in items:
		chaQuantity = chaContents.filter(typeID=item.typeID).aggregate(Sum('quantity'))["quantity__sum"]
		if not chaQuantity:
			chaQuantity = 0
		result.append({
			"typeName": item.itemName,
			"quantity": chaQuantity,
			"desiredQuantity": item.quantity,
			"pct": int(100*(float(chaQuantity) / float(item.quantity)))
			})

	return render(request, "cmlist.html", {"assets": sorted(result, key=lambda k: k['pct'])})
Ejemplo n.º 4
0
def timerboard(request):
	if not isDropbear(request.user):
		return render(request, 'error.html', {'title': '403 - Forbidden', 'description': 'You are not a member.'})

	status = None
	if request.method == "POST":
		delete = request.POST.get('delete', False)
		delid = request.POST.get('id', False)

		if delete and delid:
			Timer.objects.filter(id=delid).delete()
		else:

			target = request.POST.get('target', False)
			date = request.POST.get('date', False)
			hours = request.POST.get('hours', False)
			minutes = request.POST.get('minutes', False)

			if target and date and hours and minutes:
				try:
					d = datetime.strptime(date + hours + ":" + minutes, "%m/%d/%Y%H:%M")
					t = Timer()
					t.target = target
					t.time = d
					t.note = "-"
					t.creator = request.user.userprofile
					t.save()
					status = "Timer Added."
					notificationText = "<a href='"+reverse('core:playerProfile', kwargs={"profileName": slugify(request.user.userprofile)})+"'>"+unicode(request.user.userprofile)+"</a> added a new timer for \""+target+"\" to the <a href='"+reverse('timerboard:timerboard')+"'>Timerboard.</a>"
					postNotification(Group.objects.get(name="Member"), notificationText)
				except:
					status = "Invalid Date and/or Time"
			else:
				status = "You didn't fill all the fields."

	timers = Timer.objects.all()

	active = timers.filter(time__gte=datetime.utcnow()-timedelta(hours=1)).order_by("time")
	done = timers.filter(time__lte=datetime.utcnow()-timedelta(hours=1)).order_by("time")

	return render(request, "timers.html", {'active': active, 'done': done, 'status': status})
Ejemplo n.º 5
0
def validateRedditAccounts():
    for acc in RedditAccount.objects.all():
        if not isDropbear(acc.owner.user):
            print "Deleting account", acc.name, "of user", acc.owner
            deleteRedditAccount(acc)