-
Notifications
You must be signed in to change notification settings - Fork 3
Fix consecutive slot booking issue, and UI issues #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 %}"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A suggestion, the function defined here can be defined outside if tag as the same operation is done in else! |
||
| document.getElementById("videoImage").src = "{% static image_link %}"; | ||
| }, 2000); | ||
| {% else %} | ||
|
|
@@ -48,9 +48,7 @@ <h3>SBHS live feed: Machine ID {{mid}}</h3> | |
| }, 3000); | ||
| } | ||
| } | ||
| (function(){ | ||
| image_reloader(); | ||
| })(); | ||
| image_reloader(); | ||
| {% endif %} | ||
| </script> | ||
| {% endblock %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is difference between prev_hour and next_hour, also next_plot and prev_slot?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prev_hour is "previous hour" of current hour and next_hour is "next_hour" of current_hour. prev_slot is the query to find any booked slot on prev_hour and next_slot is to find the booked slot for next_hour. Basically There should not be any consecutive booking of slots. There should be at least 1 hour gap between slot booking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So have you tested booking after an hour?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am still not convince with the code, there are many things like,
|
||
| start_time__time=next_hour) | ||
| if prev_slot.exists() or next_slot.exists(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slight not clear how this if works!
Also, better would be writing tests, but as this needs to go live ASAP so kindly check this with all the corner cases manually once.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Next slot exists if you have booked future slot in advance. |
||
| 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( | ||
|
|
@@ -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: | ||
|
|
@@ -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.' | ||
|
|
@@ -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.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can mention the exception class as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please resolve this |
||
| return redirect('moderator_dashboard') | ||
|
|
||
| delta_T = 1000 | ||
| data = subprocess.check_output("tail -n {0} {1}".format( | ||
|
|
@@ -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): | ||
|
|
@@ -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 ############################# | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.