This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserRequest(models.Model): | |
REQUEST_IMPACT = ( | |
('minor', 'Minor'), | |
('major', 'Major'), | |
('severe', 'Wake the President'), | |
) | |
name = models.CharField(max_length=200) | |
request_impact = models.CharField(max_length=10, choices=REQUEST_IMPACT) | |
datetime_supervisor_approved = models.DateTimeField(blank=True, null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserRequest(models.Model): | |
REQUEST_IMPACT = ( | |
('minor', 'Minor'), | |
('major', 'Major'), | |
('severe', 'Wake the President'), | |
) | |
name = models.CharField(max_length=200) | |
request_impact = models.CharField(max_length=10, choices=REQUEST_IMPACT) | |
datetime_supervisor_approved = models.DateTimeField(blank=True, null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_request_calendar(request): | |
# there's actually some filtering happening but we'll use all() for brevity | |
user_requests = UserRequest.objects.all() | |
user_requests = sorted(user_requests, key=lambda ur: (ur.calendar_date, ur.request_impact)) | |
# rest of view function and return here ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Registrant(models.Model): | |
first_name = models.CharField(max_length=50, verbose_name='First Name') | |
last_name = models.CharField(max_length=50, verbose_name='Last Name') | |
email = models.EmailField(max_length=100, unique=True, verbose_name='Email') | |
password = models.CharField(max_length=100, verbose_name='Password') | |
phone = models.CharField(max_length=20, verbose_name='Phone') | |
address1 = models.CharField(max_length=100, verbose_name='Address') | |
address2 = models.CharField(max_length=100, blank=True, null=True, verbose_name='Address (cont.)') | |
city = models.CharField(max_length=100, verbose_name='City') | |
state = models.CharField(max_length=100, verbose_name='State/Province') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SponsorManager(models.Manager): | |
def with_sponsorship_totals(self): | |
from django.db import connection | |
cursor = connection.cursor() | |
cursor.execute(""" | |
SELECT s.id, | |
s.registrant_sponsoring_id, | |
SUM(s.sponsorship_amount) AS total_sponsorship_amount, | |
r.first_name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from django.http import HttpResponse | |
# other imports here ... | |
@login_required | |
def registrant_email_dump(request): | |
response = HttpResponse(content_type='text/csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addLeaveRow() { | |
var totalFormsField = $('#id_form-TOTAL_FORMS'); | |
var nextFormNum = parseInt(totalFormsField.val()); | |
$('#add_leave_row').addClass('disabled'); | |
$('#loading').show(); | |
$.ajax({ | |
url: '/leave/leave-form/' + nextFormNum + '/', | |
type: 'GET' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="leaveForm{{ form_num }}" class="row row-tall row-bottom-border leaveForm"> | |
<div class="form-group col-sm-4"> | |
<div class="row"> | |
<div class="col-xs-8"> | |
<label for="id_form-{{ form_num }}-date_start" class="sr-only">From</label> | |
<div class="input-group{% if leave_form.date_start.errors %} has-error{% endif %}"> | |
<span class="input-group-addon addon-small hidden-sm"><i class="fa fa-calendar"></i></span> | |
<input id="id_form-{{ form_num }}-date_start" name="form-{{ form_num }}-date_start" class="datepicker form-control input-sm leaveFormInput" placeholder="mm/dd/yyyy" type="text" value="{{ leave_form.date_start.value|default_if_none:'' }}" /> | |
{% if leave_form.date_start.errors %} | |
<span class="input-group-addon addon-small"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="javascript:void(0);" onclick="deleteLeaveRow(this);" class="remove muted pull-right"> | |
<div class="fa fa-times fa-lg" title="Delete day off" alt="Delete day off"></div><span class="visible-xs">Remove Day</span> | |
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteLeaveRow(deleteLink) { | |
var totalFormsField = $('#id_form-TOTAL_FORMS'); | |
var totalForms = parseInt(totalFormsField.val()) - 1; | |
totalFormsField.val(totalForms); | |
$(deleteLink).closest('.leaveForm').remove(); | |
// for formset functionality to work properly, need to update all existing form ids so they're sequential | |
updateFormElementIndices('leaveForm'); |
OlderNewer