@@ -54,7 +54,7 | |||||
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"> |
|
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 | <span class="glyphicon glyphicon-stop" aria-hidden="true"></span> |
|
55 | <span class="glyphicon glyphicon-stop" aria-hidden="true"></span> | |
56 | </button> |
|
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 | <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> |
|
58 | <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> | |
59 | </button> |
|
59 | </button> | |
60 | </h4> |
|
60 | </h4> | |
@@ -112,6 +112,11 | |||||
112 | //alert($(this).data('url')); |
|
112 | //alert($(this).data('url')); | |
113 | document.location = $(this).data('url'); |
|
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 | $(".clickable-row").click(function() { |
|
121 | $(".clickable-row").click(function() { | |
117 | document.location = $(this).data("href"); |
|
122 | document.location = $(this).data("href"); |
@@ -46,5 +46,6 urlpatterns = ( | |||||
46 | url(r'^operation/search/(?P<id_camp>-?\d+)/$', 'apps.main.views.operation_search', name='url_operation_search'), |
|
46 | url(r'^operation/search/(?P<id_camp>-?\d+)/$', 'apps.main.views.operation_search', name='url_operation_search'), | |
47 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/play/$', 'apps.main.views.radar_play', name='url_radar_play'), |
|
47 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/play/$', 'apps.main.views.radar_play', name='url_radar_play'), | |
48 | url(r'^operation/(?P<id_camp>-?\d+)/radar/(?P<id_radar>-?\d+)/stop/$', 'apps.main.views.radar_stop', name='url_radar_stop'), |
|
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 | from django.http import HttpResponseRedirect |
|
2 | from django.http import HttpResponseRedirect | |
3 | from django.core.urlresolvers import reverse |
|
3 | from django.core.urlresolvers import reverse | |
4 | from django.contrib import messages |
|
4 | from django.contrib import messages | |
|
5 | from datetime import datetime | |||
5 |
|
6 | |||
6 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm |
|
7 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm | |
7 | from .forms import OperationSearchForm |
|
8 | from .forms import OperationSearchForm | |
@@ -73,34 +74,6 def location(request, id_loc): | |||||
73 |
|
74 | |||
74 | return render(request, 'location.html', kwargs) |
|
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 | def location_new(request): |
|
78 | def location_new(request): | |
106 |
|
79 | |||
@@ -868,8 +841,8 def operation(request, id_camp=None): | |||||
868 | return redirect('url_operation', id_camp=campaign.id) |
|
841 | return redirect('url_operation', id_camp=campaign.id) | |
869 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
842 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() | |
870 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
843 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) | |
871 | for exs in experiments: |
|
844 | #for exs in experiments: | |
872 | exs.get_status() |
|
845 | # exs.get_status() | |
873 | locations= Location.objects.filter(experiment=experiments).distinct() |
|
846 | locations= Location.objects.filter(experiment=experiments).distinct() | |
874 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] |
|
847 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] | |
875 | kwargs = {} |
|
848 | kwargs = {} | |
@@ -915,8 +888,8 def operation_search(request, id_camp=None): | |||||
915 |
|
888 | |||
916 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
889 | #locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() | |
917 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
890 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) | |
918 | for exs in experiments: |
|
891 | #for exs in experiments: | |
919 | exs.get_status() |
|
892 | # exs.get_status() | |
920 | locations= Location.objects.filter(experiment=experiments).distinct() |
|
893 | locations= Location.objects.filter(experiment=experiments).distinct() | |
921 | form = OperationSearchForm(initial={'campaign': campaign.id}) |
|
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 | def radar_play(request, id_camp, id_radar): |
|
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 | route = request.META['HTTP_REFERER'] |
|
930 | route = request.META['HTTP_REFERER'] | |
947 | route = str(route) |
|
931 | route = str(route) | |
@@ -950,6 +934,7 def radar_play(request, id_camp, id_radar): | |||||
950 | else: |
|
934 | else: | |
951 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) |
|
935 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) | |
952 |
|
936 | |||
|
937 | ||||
953 | def radar_stop(request, id_camp, id_radar): |
|
938 | def radar_stop(request, id_camp, id_radar): | |
954 |
|
939 | |||
955 | route = request.META['HTTP_REFERER'] |
|
940 | route = request.META['HTTP_REFERER'] | |
@@ -959,3 +944,19 def radar_stop(request, id_camp, id_radar): | |||||
959 | else: |
|
944 | else: | |
960 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) |
|
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