Skip to content

Commit

Permalink
Fix consecutive slot booking issue, and UI issues
Browse files Browse the repository at this point in the history
- Fix consecutive slot booking issue.
- Add Forum and Contact us in SBHSInfocenter dropdown.
- Disable Refresh button in show_video for 3 seconds.
  • Loading branch information
CruiseDevice committed Dec 18, 2018
1 parent 44b7053 commit c2df01e
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 36 deletions.
10 changes: 5 additions & 5 deletions sbhs/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def production_details(request):
Context processor to access settings.py CONSTANTS in django
template.
"""
return {
'sitename':'vlabs.iitb.ac.in/sbhs',
'domain':settings.PRODUCTION_URL,
'vlabs_team':settings.SENDER_NAME,
}
context={}
context['sitename'] = request.META['HTTP_HOST']
context['domain'] = settings.PRODUCTION_URL
context['vlabs_team'] = settings.SENDER_NAME
return context
5 changes: 5 additions & 0 deletions sbhs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

MOD_GROUP_NAME = 'moderator'

SLOT_TYPES = (
('cs','CS'),
('as','AS'),
)

def create_group(group_name, app_label):
try:
Expand Down Expand Up @@ -146,6 +150,7 @@ class Slot(models.Model):
end_time = models.DateTimeField("End time of a slot",
default=timezone.now()+timedelta(
minutes=settings.SLOT_DURATION))
type_ = models.CharField(max_length=10, choices=SLOT_TYPES)

objects = SlotManager()

Expand Down
3 changes: 2 additions & 1 deletion sbhs/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
<li><a style="padding-top: 10px;" class="dropdown-item" href="{% url 'pages_info'%}#info">Info</a></li>
<li><a class="dropdown-item" href="{% url 'pages_info'%}#theory">Theory</a><li>
<li><a class="dropdown-item" href="{% url 'pages_info'%}#procedure">Procedure</a></li>
<li><a class = "dropdown-item" href="{% url 'pages_feedback' %}#contact">Contact Us</a></li>
<li><a class = "dropdown-item" href="http://sbhs.os-hardware.in/forum" target="_blank">Forums</a></li>
</ul>
</div>
</li>
Expand All @@ -78,7 +80,6 @@

<div id = "body">
<div class="content">

{% if messages %}
<ul class = "messages">
{% for message in messages %}
Expand Down
1 change: 0 additions & 1 deletion sbhs/templates/dashboard/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{% endblock %}
{% block headerfiles %}

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script type="{% static 'js/jquery-ui.js' %}"></script>
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery.datetimepicker.css' %}"/>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"/>
Expand Down
2 changes: 1 addition & 1 deletion sbhs/templates/dashboard/show_all_boards.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h4>All Active Boards</h4>
<td><span class = "label label-{% if board.online %}success{% else %}danger{% endif %}">{% if board.online %}On{% else %}Off{% endif %}</span></td>
<td><a href = "{% url 'show_video_to_moderator' board.mid %}">View Image</a></td>
<td><a href = "{% url 'profile' board.mid %}">View Profile</a></td>
<td><a href = "{% url 'download_log' board.mid %}" target="_blank">Download</a></td>
<td><a href = "{% url 'download_log' board.mid %}">Download</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down
13 changes: 6 additions & 7 deletions sbhs/templates/pages/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
{% block content %}
<div class="container">
<div class="row">
<div class="span12">
<div class="span12" id="contact">
<h2>Feedback / Contact Us</h2>
<br>
<br>
<p>
<h5>Write a mail to <a href="mailto:[email protected]">sbhs[at]os-hardware[dot]in</a> to provide a feedback on SBHS virtual lab experience. If you have any questions, please use the <a href="http://sbhs.os-hardware.in/forum" target="_blank">forum</a>.
</h5>
</p>
<hr>
<p>
<h5>Write a mail to <a href="mailto:[email protected]">sbhs[at]os-hardware[dot]in</a> to provide a feedback on SBHS virtual lab experience.
</h5>
</p>
<br>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sbhs/templates/pages/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h4>
</div>
</center><br>
<h4>
<strong>For more information please read the pdf</strong>
<strong><p><strong>For more information about the procedure, please read the pdf</strong>.</p></strong>
</h4>
<center>
<div class="embed-responsive embed-responsive-16by9">
Expand Down
6 changes: 3 additions & 3 deletions sbhs/templates/registration/password_reset_email.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ sitename }}.{% endblocktrans %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{sitename}}.{% endblocktrans %}

{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
{{ protocol }}://{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}

{% trans "Thanks for using our site!" %}

{% blocktrans %}The {{ vlabs_team }} team{% endblocktrans %}
{% blocktrans %}The SBHS Vlabs team{% endblocktrans %}

{% endautoescape %}
4 changes: 2 additions & 2 deletions sbhs/templates/slot/create_slot.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar nav-stacked nav-pills red">
<li class = "active">
<a href="#tab_a" data-toggle="pill">Create Slot</a>
<a href="#tab_a" data-toggle="pill">Book Slot</a>
</li>
<li>
<a href="#tab_b" data-toggle="pill">View/Delete slot</a>
Expand All @@ -43,7 +43,7 @@ <h4>Book future slots:</h4>
<br>
<b>Book for a given date:</b><br/>
{{form.as_p}}
<button class="btn btn-primary" type="submit" name='book_date' value='book_date'>Book Date</button><br/>
<button class="btn btn-primary" type="submit" name='book_date' value='book_date'>Book Slot</button><br/>
</div>
</form>
<div class = "tab-content col-md-10">
Expand Down
8 changes: 3 additions & 5 deletions sbhs/templates/webcam/show_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ <h3>SBHS live feed: Machine ID {{mid}}</h3>
</div>
</div>
</div>
<script type="text/javascript">
<script>
{% if request.user.profile.is_moderator %}
setInterval(function(){
var refresh = new Image();
refresh.src = "{% static image_link %}";
refresh.src = "{% static image_link %}";
document.getElementById("videoImage").src = "{% static image_link %}";
}, 2000);
{% else %}
Expand All @@ -48,9 +48,7 @@ <h3>SBHS live feed: Machine ID {{mid}}</h3>
}, 3000);
}
}
(function(){
image_reloader();
})();
image_reloader();
{% endif %}
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion sbhs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# restore password urls
url(r'^account/password-reset/$', password_reset,
{'template_name': 'registration/password_reset_form.html'},
{'template_name': 'registration/password_reset_form.html',},
name='password_reset'),
url(r'^account/password-reset/done/$', password_reset_done,
{'template_name': 'registration/password_reset_done.html'},
Expand Down
46 changes: 37 additions & 9 deletions sbhs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,31 @@ def slot_new(request):
form = SlotCreationForm(request.POST)
if form.is_valid():
new_slot = form.save(commit=False)

new_slot_date = new_slot.start_time.date()
new_slot_time = new_slot.start_time.time()
prev_hour = dt.combine(
new_slot_date,time(
new_slot_time.hour,00)) - timedelta(hours=1)
prev_slot = slot_history.filter(start_time__date=new_slot_date,
start_time__time=prev_hour)
next_hour = dt.combine(
new_slot_date,time(
new_slot_time.hour,00)) + timedelta(hours=1)
next_slot = slot_history.filter(start_time__date=new_slot_date,
start_time__time=next_hour)
if prev_slot.exists() or next_slot.exists():
messages.error(request,
'Cannot book two consecutive slots.')
return redirect('slot_new')

new_slot_date_slots = slot_history.filter(
start_time__date=new_slot_date
start_time__date=new_slot_date,
slot_type='as'
)
if len(new_slot_date_slots) >= settings.LIMIT:
messages.error(request,'Cannot Book more than {0} \
slots in advance in a day'.format(settings.LIMIT))
return redirect('slot_new')
else:
if new_slot.start_time.time():
if Slot.objects.check_booked_slots(
Expand All @@ -344,24 +360,30 @@ def slot_new(request):
)
)
new_slot.user = user
new_slot.slot_type='as'
new_slot.save()
messages.success(request,
'Slot booked successfully.'
)
return redirect('slot_new')
else:
messages.error(request,
'Start time selected'
+ ' is before today.'
+ 'Please choose again.'
'Either you have not selected'
+ ' Time or the selected Time'
+ ' is before current time.'
+ ' Please choose again.'
)
return redirect('slot_new')
else:
messages.error(request,
'Slot is already booked.'
+ ' Try the next slot.'
)
return redirect('slot_new')
else:
messages.error(request,'Please also select Time with \
Date.')
return redirect('slot_new')

if request.POST.get("book_now") == "book_now":
if not current_slot:
Expand All @@ -373,14 +395,17 @@ def slot_new(request):
time(now.hour,00)),
end_time=dt.combine(now.date(),
time(now.hour, settings.SLOT_DURATION)
)
),
slot_type='cs'
)
messages.success(request,'Slot booked successfully.')
return redirect('slot_new')
else:
messages.error(request,
'Slot is booked by someone else.'
+ ' Try the next slot.'
)
return redirect('slot_new')
else:
messages.error(request,'Slot is already booked for \
current time. Please select a future slot.'
Expand Down Expand Up @@ -660,7 +685,8 @@ def profile(request, mid):
f = open(filename, "r")
f.close()
except:
raise Http404("Log does not exist for this profile.")
messages.error(request,'Log does not exist for this profile.')
return redirect('moderator_dashboard')

delta_T = 1000
data = subprocess.check_output("tail -n {0} {1}".format(
Expand Down Expand Up @@ -714,7 +740,8 @@ def download_log(request, mid):
f.close()
return HttpResponse(data, content_type='text/text')
except:
return HttpResponse("Requested log file does not exist")
messages.error(request,"Requested log file does not exist.")
return redirect('moderator_dashboard')


def zipdir(path,ziph):
Expand Down Expand Up @@ -935,7 +962,8 @@ def download_file(request, experiment_id):
).read())
return response
except:
raise Http404("Requested files does not exist.")
messages.error(request,'Requested file does not exist.')
return redirect('fetch_logs')


################## Webcam Views #############################
Expand Down

0 comments on commit c2df01e

Please sign in to comment.