Skip to content

Commit

Permalink
fixed group selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Helen Chen committed Apr 26, 2020
1 parent 92e1c4e commit 7a7fcd5
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 32 deletions.
Binary file modified pacApp/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file modified pacApp/__pycache__/views.cpython-37.pyc
Binary file not shown.
16 changes: 11 additions & 5 deletions pacApp/static/pacApp/assets/css/schedule.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
table {
border-collapse:collapse;
}


input[type="radio"], {
-webkit-appearance: radio;
cursor: pointer;
Expand Down Expand Up @@ -27,21 +32,22 @@ input[type="radio"]#group:checked ~ .reveal-if-activeGroup {
overflow: visible;
}

th tr{
th {
text-align:left;

}

.studio {
padding:6px 12px;
padding-left:20px;
padding-right:0px;
}


/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
padding: 6px 12px;
padding: 6px 12px;
width:100%;
position:relative;
}
Expand Down Expand Up @@ -71,10 +77,10 @@ th tr{
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
width: 100%;
overflow:hidden;

}

Expand Down
6 changes: 0 additions & 6 deletions pacApp/static/pacApp/assets/css/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ table {
border-collapse: collapse;
}

th, td {
font-weight: unset;
padding-right: 10px;
text-align:left;
}

.column100 {
width: 130px;
}
Expand Down
26 changes: 23 additions & 3 deletions pacApp/static/pacApp/assets/js/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function openDay(tab, id) {
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(tab).style.display = "block";
document.getElementById(id).className += " active";
var weekdays= {'sun':0,'mon':1,'tue':2,'wed':3,'thu':4,'fri':5,'sat':6};
var date = $('#'+id).data('date').split('-');
console.log(date)
var reformatted = date[1] + '/' + date[2] + '/' + date[0].substring(2,4);
Expand Down Expand Up @@ -194,7 +195,7 @@ function handleresponse(response)
}


function setupWeek()
function setupWeek(type)
// date = yyyy-mm-dd
{
// in prepation for the today tab - if it is on the current day, has this feature
Expand All @@ -204,18 +205,36 @@ function setupWeek()
groups = 'None'
}
console.log(groups);


var active = document.getElementsByClassName('active')[0].id[1];
console.log(active);

var curr = $('#curr').val();
console.log(curr);
let url = 'update';
request = $.ajax(
if (type == 'week') {
request = $.ajax(
{
type: "GET",
url: url,
data: {'newdate': curr,
'selectgroups': groups},
success: handleresponse,
}
);
}
else if (type == 'group') {
request = $.ajax(
{
type: "GET",
url: url,
data: {'newdate': curr,
'selectgroups': groups,
'groupday': active},
success: handleresponse,
}
);
}
}

function setGroups() {
Expand All @@ -231,6 +250,7 @@ function setGroups() {
}



// sendbook gathers all the stuff necessary to make a booking
function sendbook(id) {
// checks whether or not there are selected groups
Expand Down
8 changes: 3 additions & 5 deletions pacApp/templates/pacApp/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="stylesheet" type="text/css" href="/static/pacApp/assets/css/schedule.css">
<link rel="stylesheet" type="text/css" href="static/pacApp/assets/css/table.css" />
<link rel="stylesheet" type="text/css" href="static/pacApp/assets/css/main.css" />

<script type="application/javascript" src="/static/pacApp/assets/js/input.js"></script>
<script type="application/javascript" src="/static/pacApp/assets/js/schedule.js"></script>
<script type="application/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
Expand All @@ -14,9 +15,6 @@
th, td {
cursor: pointer;
}
table {
border-collapse: collapse;
}
</style>
{% endif %}

Expand Down Expand Up @@ -51,7 +49,7 @@ <h1>Booking Schedule</h1>
<div id="scheduletable">
{% include 'templates/pacApp/tableElements/daystab.html' %}
{% include 'templates/pacApp/tableElements/table.html' %}
{% include 'templates/pacApp/tableElements/groupSelection.html' %}
{% include 'templates/pacApp/tableElements/groupSelection.html'%}
</div>

<!-- the pop up modal -->
Expand All @@ -75,7 +73,7 @@ <h1>Booking Schedule</h1>
$('#headerschedule').css('display','none');
}
else {
$('#scheduletable').css('margin', '20px');
/* $('#scheduletable').css('margin', '20px'); */
$('#booking').css('display','none');
}
// very initial set up of the document, we use today's date to set up active tab
Expand Down
1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/friday.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@
</div>
</div>
</div>

12 changes: 6 additions & 6 deletions pacApp/templates/pacApp/tableElements/groupSelection.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div>
<input type="checkbox" id="Sympoh" name="selectGroups" value="Sympoh" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
<div id="groupselect" data-date="{{weekday}}">
<input type="checkbox" id="Sympoh" name="selectGroups" value="Sympoh" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
<label for="Sympoh">Sympoh</label>
<input type="checkbox" id="Disiac" name="selectGroups" value="Disiac" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
<input type="checkbox" id="Disiac" name="selectGroups" value="Disiac" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
<label for="Disiac">Disiac</label>
<input type="checkbox" id="BAC" name="selectGroups" value="BAC" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
<input type="checkbox" id="BAC" name="selectGroups" value="BAC" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
<label for="BAC">BAC</label>
<input type="checkbox" id="PUB" name="selectGroups" value="PUB" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
<input type="checkbox" id="PUB" name="selectGroups" value="PUB" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
<label for="PUB">PUB</label>
<input type="checkbox" id="Expression" name="selectGroups" value="Expression" style="-webkit-appearance: checkbox; cursor:pointer;" onchange="setupWeek();">
<input type="checkbox" id="Expression" name="selectGroups" value="Expression" style="-webkit-appearance: checkbox; cursor:pointer;" onchange="setupWeek('group');">
<label for="Expression">Expression</label>
</div>
1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/monday.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@
</div>
</div>
</div>

1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/saturday.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@
</div>
</div>
</div>

15 changes: 10 additions & 5 deletions pacApp/templates/pacApp/tableElements/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="tablinks" id="d6" data-date="{{sat}}" onclick="openDay('sat', this.id)">Saturday
<br><span id="d6date" style="display:none"></span>
</div>
<div class="tablinks"><input type="date" max="2999-12-31" autocomplete="on" id="curr"></div>
<div class="tablinks"><input type="date" max="2999-12-31" autocomplete="on" id="curr" onchange="setupWeek('week');"></div>
<div class="tablinks" id="booking" style="background-color:#b76e79; color:white; float:right; margin-top:15px">
<a style="text-decoration-line:none;" href="schedule">Booking</a>
</div>
Expand All @@ -45,6 +45,7 @@
<div class="tabcontent" id="sat">{% include 'templates/pacApp/tableElements/saturday.html'%}</div>
</div>


<!-- renders this page to be displayed when changes made -->
<!-- for setting up the data initially -->
<script type="text/javascript">
Expand Down Expand Up @@ -226,21 +227,25 @@
}
// $('td').css('cursor','pointer');
var weekday = parseInt("{{weekday}}");
// console.log(weekday);
var current = "{{currentdate}}";
console.log(weekday);
var currday = "{{currday}}";
if (currday != 'None') {
$('#d'+currday).addClass('today');
}
$('#curr').val("{{formatdate}}");
$('#curr').on('change', setupWeek);

var daysofweek = ['sun','mon','tue','wed','thu','fri','sat'];
openDay(daysofweek[weekday], 'd'+weekday);


var edit = "{{editable}}";
console.log(edit);
if (edit == 'False') {
console.log('is false and already on home page');
$('#headerschedule').css('display','none');
}
else {
$('#scheduletable').css('margin', '20px');

$('#booking').css('display','none');
}
</script>
1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/thursday.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@
</div>
</div>
</div>

1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/tuesday.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@
</div>
</div>
</div>

1 change: 1 addition & 0 deletions pacApp/templates/pacApp/tableElements/wednesday.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@
</div>
</div>
</div>

14 changes: 14 additions & 0 deletions pacApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ def error_500(request):
return render(request,'templates/pacApp/404.html', data)

def createContext(startdate, endweek, newdate, groups, getGroups):
actualdate = date.today()
currday = 'None'
week = {}
for i in range(7):
# week.append((startdate + timedelta(days=i)).strftime('%Y-%m-%d-%w'))
week[(startdate + timedelta(days=i)).strftime('%w')] = (startdate + timedelta(days=i)).strftime('%Y-%m-%d')
if (startdate + timedelta(days=i)).strftime('%Y-%m-%d') == actualdate.strftime('%Y-%m-%d'):
currday = actualdate.strftime('%w')
# print(week)

studioList = {'bloomberg':0, 'dillondance':1, 'dillonmar':2, 'dillonmpr': 3, 'murphy': 4, 'ns':5,'nswarmup': 6, 'nstheatre': 7, 'whitman': 8, 'wilcox': 9}
Expand All @@ -54,6 +58,7 @@ def createContext(startdate, endweek, newdate, groups, getGroups):
'Whitman': Booking.objects.filter(studio_id=8).filter(booking_date__range=[startdate, endweek]),
'Wilcox': Booking.objects.filter(studio_id=9).filter(booking_date__range=[startdate, endweek]),
'newdate': newdate, 'formatdate': formatdate, 'weekday': int(startdate.strftime('%w')), 'sun': week['0'],
'currday':currday,
'mon': week['1'], 'tue': week['2'], 'wed': week['3'],
'thu': week['4'], 'fri': week['5'], 'sat': week['6']}
if getGroups == True:
Expand Down Expand Up @@ -137,6 +142,7 @@ def update(request:HttpResponse):
request.GET.get('endtime'), request.GET.get('day'))
retdate = request.GET.get('newdate').split('-')
startdate = datetime.date(int(retdate[0]),int(retdate[1]),int(retdate[2]))
print(startdate)
endweek = startdate + timedelta(days=6)
newdate = request.GET.get('newdate')
print(newdate)
Expand All @@ -151,10 +157,18 @@ def update(request:HttpResponse):
context = createContext(startdate, endweek, newdate, groups, getGroups)
if weekday != None:
context['weekday'] = weekday
groupday = request.GET.get('groupday');
print(weekday)
print('groupday is')
print(groupday)
if weekday == None and groupday != None:
context['weekday'] = groupday
context['editable'] = True

return render(request, "templates/pacApp/tableElements/table.html", context)



def insert_space_item(request: HttpResponse):
return redirect('/schedule')

Expand Down
Binary file modified pacProject/__pycache__/settings.cpython-37.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions pacProject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
SECRET_KEY = '59c!&ax&$m&aoy#!&((_l741@@-s6(86f4g8qxu1w!4^v!65d9'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
#DEBUG = True
#DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['pac-schedule.herokuapp.com/']

Expand Down

0 comments on commit 7a7fcd5

Please sign in to comment.