Skip to content

Commit 7a7fcd5

Browse files
author
Helen Chen
committed
fixed group selection
1 parent 92e1c4e commit 7a7fcd5

File tree

17 files changed

+75
-32
lines changed

17 files changed

+75
-32
lines changed
0 Bytes
Binary file not shown.
219 Bytes
Binary file not shown.

pacApp/static/pacApp/assets/css/schedule.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
table {
2+
border-collapse:collapse;
3+
}
4+
5+
16
input[type="radio"], {
27
-webkit-appearance: radio;
38
cursor: pointer;
@@ -27,21 +32,22 @@ input[type="radio"]#group:checked ~ .reveal-if-activeGroup {
2732
overflow: visible;
2833
}
2934

30-
th tr{
35+
th {
3136
text-align:left;
32-
3337
}
3438

3539
.studio {
36-
padding:6px 12px;
40+
padding-left:20px;
41+
padding-right:0px;
3742
}
3843

44+
3945
/* Style the tab */
4046
.tab {
4147
overflow: hidden;
4248
border: 1px solid #ccc;
4349
background-color: #f1f1f1;
44-
padding: 6px 12px;
50+
padding: 6px 12px;
4551
width:100%;
4652
position:relative;
4753
}
@@ -71,10 +77,10 @@ th tr{
7177
/* Style the tab content */
7278
.tabcontent {
7379
display: none;
74-
padding: 6px 12px;
7580
border: 1px solid #ccc;
7681
border-top: none;
7782
width: 100%;
83+
overflow:hidden;
7884

7985
}
8086

pacApp/static/pacApp/assets/css/table.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ table {
2525
border-collapse: collapse;
2626
}
2727

28-
th, td {
29-
font-weight: unset;
30-
padding-right: 10px;
31-
text-align:left;
32-
}
33-
3428
.column100 {
3529
width: 130px;
3630
}

pacApp/static/pacApp/assets/js/schedule.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function openDay(tab, id) {
2222
// Show the current tab, and add an "active" class to the button that opened the tab
2323
document.getElementById(tab).style.display = "block";
2424
document.getElementById(id).className += " active";
25+
var weekdays= {'sun':0,'mon':1,'tue':2,'wed':3,'thu':4,'fri':5,'sat':6};
2526
var date = $('#'+id).data('date').split('-');
2627
console.log(date)
2728
var reformatted = date[1] + '/' + date[2] + '/' + date[0].substring(2,4);
@@ -194,7 +195,7 @@ function handleresponse(response)
194195
}
195196

196197

197-
function setupWeek()
198+
function setupWeek(type)
198199
// date = yyyy-mm-dd
199200
{
200201
// in prepation for the today tab - if it is on the current day, has this feature
@@ -204,18 +205,36 @@ function setupWeek()
204205
groups = 'None'
205206
}
206207
console.log(groups);
207-
208+
209+
var active = document.getElementsByClassName('active')[0].id[1];
210+
console.log(active);
211+
208212
var curr = $('#curr').val();
213+
console.log(curr);
209214
let url = 'update';
210-
request = $.ajax(
215+
if (type == 'week') {
216+
request = $.ajax(
211217
{
212218
type: "GET",
213219
url: url,
214220
data: {'newdate': curr,
215221
'selectgroups': groups},
222+
success: handleresponse,
223+
}
224+
);
225+
}
226+
else if (type == 'group') {
227+
request = $.ajax(
228+
{
229+
type: "GET",
230+
url: url,
231+
data: {'newdate': curr,
232+
'selectgroups': groups,
233+
'groupday': active},
216234
success: handleresponse,
217235
}
218236
);
237+
}
219238
}
220239

221240
function setGroups() {
@@ -231,6 +250,7 @@ function setGroups() {
231250
}
232251

233252

253+
234254
// sendbook gathers all the stuff necessary to make a booking
235255
function sendbook(id) {
236256
// checks whether or not there are selected groups

pacApp/templates/pacApp/schedule.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<link rel="stylesheet" type="text/css" href="/static/pacApp/assets/css/schedule.css">
66
<link rel="stylesheet" type="text/css" href="static/pacApp/assets/css/table.css" />
77
<link rel="stylesheet" type="text/css" href="static/pacApp/assets/css/main.css" />
8+
89
<script type="application/javascript" src="/static/pacApp/assets/js/input.js"></script>
910
<script type="application/javascript" src="/static/pacApp/assets/js/schedule.js"></script>
1011
<script type="application/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
@@ -14,9 +15,6 @@
1415
th, td {
1516
cursor: pointer;
1617
}
17-
table {
18-
border-collapse: collapse;
19-
}
2018
</style>
2119
{% endif %}
2220

@@ -51,7 +49,7 @@ <h1>Booking Schedule</h1>
5149
<div id="scheduletable">
5250
{% include 'templates/pacApp/tableElements/daystab.html' %}
5351
{% include 'templates/pacApp/tableElements/table.html' %}
54-
{% include 'templates/pacApp/tableElements/groupSelection.html' %}
52+
{% include 'templates/pacApp/tableElements/groupSelection.html'%}
5553
</div>
5654

5755
<!-- the pop up modal -->
@@ -75,7 +73,7 @@ <h1>Booking Schedule</h1>
7573
$('#headerschedule').css('display','none');
7674
}
7775
else {
78-
$('#scheduletable').css('margin', '20px');
76+
/* $('#scheduletable').css('margin', '20px'); */
7977
$('#booking').css('display','none');
8078
}
8179
// very initial set up of the document, we use today's date to set up active tab

pacApp/templates/pacApp/tableElements/friday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,4 @@
114114
</div>
115115
</div>
116116
</div>
117+
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<div>
2-
<input type="checkbox" id="Sympoh" name="selectGroups" value="Sympoh" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
1+
<div id="groupselect" data-date="{{weekday}}">
2+
<input type="checkbox" id="Sympoh" name="selectGroups" value="Sympoh" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
33
<label for="Sympoh">Sympoh</label>
4-
<input type="checkbox" id="Disiac" name="selectGroups" value="Disiac" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
4+
<input type="checkbox" id="Disiac" name="selectGroups" value="Disiac" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
55
<label for="Disiac">Disiac</label>
6-
<input type="checkbox" id="BAC" name="selectGroups" value="BAC" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
6+
<input type="checkbox" id="BAC" name="selectGroups" value="BAC" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
77
<label for="BAC">BAC</label>
8-
<input type="checkbox" id="PUB" name="selectGroups" value="PUB" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek();">
8+
<input type="checkbox" id="PUB" name="selectGroups" value="PUB" style="-webkit-appearance: checkbox; cursor: pointer;" onchange="setupWeek('group');">
99
<label for="PUB">PUB</label>
10-
<input type="checkbox" id="Expression" name="selectGroups" value="Expression" style="-webkit-appearance: checkbox; cursor:pointer;" onchange="setupWeek();">
10+
<input type="checkbox" id="Expression" name="selectGroups" value="Expression" style="-webkit-appearance: checkbox; cursor:pointer;" onchange="setupWeek('group');">
1111
<label for="Expression">Expression</label>
1212
</div>

pacApp/templates/pacApp/tableElements/monday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@
110110
</div>
111111
</div>
112112
</div>
113+

pacApp/templates/pacApp/tableElements/saturday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@
108108
</div>
109109
</div>
110110
</div>
111+

pacApp/templates/pacApp/tableElements/table.html

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

48+
4849
<!-- renders this page to be displayed when changes made -->
4950
<!-- for setting up the data initially -->
5051
<script type="text/javascript">
@@ -226,21 +227,25 @@
226227
}
227228
// $('td').css('cursor','pointer');
228229
var weekday = parseInt("{{weekday}}");
229-
// console.log(weekday);
230-
var current = "{{currentdate}}";
230+
console.log(weekday);
231+
var currday = "{{currday}}";
232+
if (currday != 'None') {
233+
$('#d'+currday).addClass('today');
234+
}
231235
$('#curr').val("{{formatdate}}");
232-
$('#curr').on('change', setupWeek);
236+
233237
var daysofweek = ['sun','mon','tue','wed','thu','fri','sat'];
234238
openDay(daysofweek[weekday], 'd'+weekday);
235239

240+
236241
var edit = "{{editable}}";
237242
console.log(edit);
238243
if (edit == 'False') {
239244
console.log('is false and already on home page');
240245
$('#headerschedule').css('display','none');
241246
}
242247
else {
243-
$('#scheduletable').css('margin', '20px');
248+
244249
$('#booking').css('display','none');
245250
}
246251
</script>

pacApp/templates/pacApp/tableElements/thursday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@
110110
</div>
111111
</div>
112112
</div>
113+

pacApp/templates/pacApp/tableElements/tuesday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@
110110
</div>
111111
</div>
112112
</div>
113+

pacApp/templates/pacApp/tableElements/wednesday.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,4 @@
111111
</div>
112112
</div>
113113
</div>
114+

pacApp/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ def error_500(request):
2727
return render(request,'templates/pacApp/404.html', data)
2828

2929
def createContext(startdate, endweek, newdate, groups, getGroups):
30+
actualdate = date.today()
31+
currday = 'None'
3032
week = {}
3133
for i in range(7):
3234
# week.append((startdate + timedelta(days=i)).strftime('%Y-%m-%d-%w'))
3335
week[(startdate + timedelta(days=i)).strftime('%w')] = (startdate + timedelta(days=i)).strftime('%Y-%m-%d')
36+
if (startdate + timedelta(days=i)).strftime('%Y-%m-%d') == actualdate.strftime('%Y-%m-%d'):
37+
currday = actualdate.strftime('%w')
3438
# print(week)
3539

3640
studioList = {'bloomberg':0, 'dillondance':1, 'dillonmar':2, 'dillonmpr': 3, 'murphy': 4, 'ns':5,'nswarmup': 6, 'nstheatre': 7, 'whitman': 8, 'wilcox': 9}
@@ -54,6 +58,7 @@ def createContext(startdate, endweek, newdate, groups, getGroups):
5458
'Whitman': Booking.objects.filter(studio_id=8).filter(booking_date__range=[startdate, endweek]),
5559
'Wilcox': Booking.objects.filter(studio_id=9).filter(booking_date__range=[startdate, endweek]),
5660
'newdate': newdate, 'formatdate': formatdate, 'weekday': int(startdate.strftime('%w')), 'sun': week['0'],
61+
'currday':currday,
5762
'mon': week['1'], 'tue': week['2'], 'wed': week['3'],
5863
'thu': week['4'], 'fri': week['5'], 'sat': week['6']}
5964
if getGroups == True:
@@ -137,6 +142,7 @@ def update(request:HttpResponse):
137142
request.GET.get('endtime'), request.GET.get('day'))
138143
retdate = request.GET.get('newdate').split('-')
139144
startdate = datetime.date(int(retdate[0]),int(retdate[1]),int(retdate[2]))
145+
print(startdate)
140146
endweek = startdate + timedelta(days=6)
141147
newdate = request.GET.get('newdate')
142148
print(newdate)
@@ -151,10 +157,18 @@ def update(request:HttpResponse):
151157
context = createContext(startdate, endweek, newdate, groups, getGroups)
152158
if weekday != None:
153159
context['weekday'] = weekday
160+
groupday = request.GET.get('groupday');
161+
print(weekday)
162+
print('groupday is')
163+
print(groupday)
164+
if weekday == None and groupday != None:
165+
context['weekday'] = groupday
154166
context['editable'] = True
167+
155168
return render(request, "templates/pacApp/tableElements/table.html", context)
156169

157170

171+
158172
def insert_space_item(request: HttpResponse):
159173
return redirect('/schedule')
160174

0 Bytes
Binary file not shown.

pacProject/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
SECRET_KEY = '59c!&ax&$m&aoy#!&((_l741@@-s6(86f4g8qxu1w!4^v!65d9'
2525

2626
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = False
28-
#DEBUG = True
27+
#DEBUG = False
28+
DEBUG = True
2929

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

0 commit comments

Comments
 (0)