@@ -54,7 +54,7 | |||
|
54 | 54 | <button type="button" name="bt_stop" class="btn btn-primary pull-right btn-xs" data-url="{% url 'url_radar_stop' campaign.id location.id %}" aria-label="Left Align" style="margin-left: 10px"> |
|
55 | 55 | <span class="glyphicon glyphicon-stop" aria-hidden="true"></span> |
|
56 | 56 | </button> |
|
57 |
<button type="button" name="bt_refresh" class="btn btn-primary pull-right btn-xs" data-url="{% url 'url_radar_ |
|
|
57 | <button type="button" name="bt_refresh" class="btn btn-primary pull-right btn-xs" data-url="{% url 'url_radar_refresh' campaign.id location.id %}" aria-label="Left Align" style="margin-left: 10px"> | |
|
58 | 58 | <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> |
|
59 | 59 | </button> |
|
60 | 60 | </h4> |
@@ -112,6 +112,11 | |||
|
112 | 112 | //alert($(this).data('url')); |
|
113 | 113 | document.location = $(this).data('url'); |
|
114 | 114 | }); |
|
115 | ||
|
116 | //--------For REFRESH Button------- | |
|
117 | $("#accordion").on("click", "button[name=bt_refresh]", function(){ | |
|
118 | document.location = $(this).data('url'); | |
|
119 | }); | |
|
115 | 120 | |
|
116 | 121 | $(".clickable-row").click(function() { |
|
117 | 122 | document.location = $(this).data("href"); |
@@ -46,5 +46,6 urlpatterns = ( | |||
|
46 | 46 | url(r'^operation/search/(?P<id_camp>-?\d+)/$', 'apps.main.views.operation_search', name='url_operation_search'), |
|
47 | 47 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/play/$', 'apps.main.views.radar_play', name='url_radar_play'), |
|
48 | 48 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/stop/$', 'apps.main.views.radar_stop', name='url_radar_stop'), |
|
49 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/refresh/$', 'apps.main.views.radar_refresh', name='url_radar_refresh'), | |
|
49 | 50 | |
|
50 | 51 | ) |
@@ -2,6 +2,7 from django.shortcuts import render, redirect, get_object_or_404, HttpResponse | |||
|
2 | 2 | from django.http import HttpResponseRedirect |
|
3 | 3 | from django.core.urlresolvers import reverse |
|
4 | 4 | from django.contrib import messages |
|
5 | from datetime import datetime | |
|
5 | 6 | |
|
6 | 7 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm |
|
7 | 8 | from .forms import OperationSearchForm |
@@ -73,34 +74,6 def location(request, id_loc): | |||
|
73 | 74 | |
|
74 | 75 | return render(request, 'location.html', kwargs) |
|
75 | 76 | |
|
76 | #def location_play(request, id_camp, id_loc): | |
|
77 | ||
|
78 | # campaign = get_object_or_404(Campaign, pk=id_camp) | |
|
79 | # print campaign | |
|
80 | # location = get_object_or_404(Location, pk=id_loc) | |
|
81 | # experiments = Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) | |
|
82 | # locations = Location.objects.filter(pk=id_loc) | |
|
83 | ||
|
84 | # if request.method=='GET': | |
|
85 | # form = OperationForm(initial={'campaign': campaign.id}) | |
|
86 | ||
|
87 | # kwargs = {} | |
|
88 | #---Campaign | |
|
89 | # kwargs['campaign'] = campaign | |
|
90 | # kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
|
91 | #---Experiment | |
|
92 | # keys = ['id', 'name', 'start_time', 'end_time'] | |
|
93 | # kwargs['experiment_keys'] = keys[1:] | |
|
94 | # kwargs['experiments'] = experiments | |
|
95 | #---Radar | |
|
96 | # kwargs['location'] = location | |
|
97 | #---Else | |
|
98 | # kwargs['title'] = 'Campaign' | |
|
99 | # kwargs['suptitle'] = campaign.name | |
|
100 | # kwargs['form'] = form | |
|
101 | # kwargs['button'] = 'Search' | |
|
102 | ||
|
103 | # return render(request, 'operation_play.html', kwargs) | |
|
104 | 77 | |
|
105 | 78 | def location_new(request): |
|
106 | 79 | |
@@ -868,8 +841,8 def operation(request, id_camp=None): | |||
|
868 | 841 | return redirect('url_operation', id_camp=campaign.id) |
|
869 | 842 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
870 | 843 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
871 | for exs in experiments: | |
|
872 | exs.get_status() | |
|
844 | #for exs in experiments: | |
|
845 | # exs.get_status() | |
|
873 | 846 | locations= Location.objects.filter(experiment=experiments).distinct() |
|
874 | 847 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] |
|
875 | 848 | kwargs = {} |
@@ -915,8 +888,8 def operation_search(request, id_camp=None): | |||
|
915 | 888 | |
|
916 | 889 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
917 | 890 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
918 | for exs in experiments: | |
|
919 | exs.get_status() | |
|
891 | #for exs in experiments: | |
|
892 | # exs.get_status() | |
|
920 | 893 | locations= Location.objects.filter(experiment=experiments).distinct() |
|
921 | 894 | form = OperationSearchForm(initial={'campaign': campaign.id}) |
|
922 | 895 | |
@@ -942,6 +915,17 def operation_search(request, id_camp=None): | |||
|
942 | 915 | |
|
943 | 916 | |
|
944 | 917 | def radar_play(request, id_camp, id_radar): |
|
918 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
|
919 | radar = get_object_or_404(Location, pk = id_radar) | |
|
920 | experiments = Experiment.objects.filter(campaign=campaign).filter(location=radar) | |
|
921 | current_time = datetime.today() | |
|
922 | #exp = RunningExperiment( | |
|
923 | # radar = purchase_request.user_id, | |
|
924 | # running_experiment = purchase_request, | |
|
925 | # status = , | |
|
926 | # ) | |
|
927 | #new_pos.append(exp) | |
|
928 | #exp.save() | |
|
945 | 929 | |
|
946 | 930 | route = request.META['HTTP_REFERER'] |
|
947 | 931 | route = str(route) |
@@ -950,6 +934,7 def radar_play(request, id_camp, id_radar): | |||
|
950 | 934 | else: |
|
951 | 935 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) |
|
952 | 936 | |
|
937 | ||
|
953 | 938 | def radar_stop(request, id_camp, id_radar): |
|
954 | 939 | |
|
955 | 940 | route = request.META['HTTP_REFERER'] |
@@ -959,3 +944,19 def radar_stop(request, id_camp, id_radar): | |||
|
959 | 944 | else: |
|
960 | 945 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) |
|
961 | 946 | |
|
947 | ||
|
948 | def radar_refresh(request, id_camp, id_radar): | |
|
949 | ||
|
950 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
|
951 | radar = get_object_or_404(Location, pk = id_radar) | |
|
952 | experiments = Experiment.objects.filter(campaign=campaign).filter(location=radar) | |
|
953 | for exs in experiments: | |
|
954 | exs.get_status() | |
|
955 | ||
|
956 | route = request.META['HTTP_REFERER'] | |
|
957 | route = str(route) | |
|
958 | if 'search' in route: | |
|
959 | return HttpResponseRedirect(reverse('url_operation_search', args=[id_camp])) | |
|
960 | else: | |
|
961 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) | |
|
962 |
General Comments 0
You need to be logged in to leave comments.
Login now