Add a donation progress bar
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import models
|
||||
import forums.models
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
from django.db.models import Sum
|
||||
from donate.models import Donation
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
|
||||
def random_quote(request):
|
||||
quote = models.Quote.objects.order_by('?')
|
||||
@@ -14,3 +18,14 @@ def forum_activity(request):
|
||||
|
||||
def login_form(request):
|
||||
return {'login_form': AuthenticationForm()}
|
||||
|
||||
def donation_info(request):
|
||||
now = datetime.now()
|
||||
monthStart = datetime(now.year, now.month, 1)
|
||||
donations = Donation.objects.filter(created__gt=monthStart).aggregate(Sum('quantity'))['quantity__sum']
|
||||
goal = getattr(settings, 'CAMINUS_DONATION_GOAL', 0)
|
||||
if donations > goal:
|
||||
progress = 100
|
||||
else:
|
||||
progress = donations/goal*100
|
||||
return {'donation_month_total': donations, 'donation_month_goal': goal, 'donation_goal_progress': progress}
|
||||
|
@@ -171,6 +171,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
"local.context.random_quote",
|
||||
"local.context.login_form",
|
||||
"local.context.forum_activity",
|
||||
"local.context.donation_info",
|
||||
"minecraft.context.server_info",
|
||||
"appversion.context.git_version",
|
||||
"messages.context_processors.inbox",
|
||||
|
BIN
static/css/img/diamond-block.png
Normal file
BIN
static/css/img/diamond-block.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 588 B |
BIN
static/css/img/diamond.png
Normal file
BIN
static/css/img/diamond.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
@@ -424,3 +424,41 @@ fieldset {
|
||||
.topic .avatar {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#donation-slider {
|
||||
border: 2px solid black;
|
||||
margin-bottom: 1em;
|
||||
padding: 3px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#donation-progress {
|
||||
height: 25px;
|
||||
background-color: #0f0;
|
||||
background: url(img/diamond-block.png);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#donation-progress:after {
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
position: absolute;
|
||||
right: -15px;
|
||||
content: "";
|
||||
background: url(img/diamond.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#donation-text {
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
line-height: 25px;
|
||||
padding: 0px 10px;
|
||||
text-align: center;
|
||||
z-index: 1;
|
||||
color: #fff;
|
||||
background: url(img/adminium.png);
|
||||
}
|
||||
|
||||
#donation-text a {
|
||||
color: #fff;
|
||||
}
|
||||
|
@@ -132,6 +132,12 @@ s.parentNode.insertBefore(po, s);
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="grid_12">
|
||||
<div id="donation-slider">
|
||||
<div id="donation-text"><a href="{% url donate.views.index %}">Donations this month: ${{donation_month_total}} of ${{donation_month_goal}}</a></div>
|
||||
<div id="donation-progress" style="width: {{donation_goal_progress}}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% block main %}
|
||||
{% endblock main %}
|
||||
<div class="clear"></div>
|
||||
|
Reference in New Issue
Block a user