Commit 80eebb7b authored by Janez K's avatar Janez K
Browse files

managiranje streamov

parent e13167d5
......@@ -30,8 +30,12 @@
<div class="row">
<div class="span12">
<a href="#" class="btn btn-warning btn-large">Deactivate</a>
<a href="#" class="btn btn-warning btn-danger btn-large">Reset</a>
{% if stream.active %}
<a href="{% url 'deactivate stream' stream.pk %}" class="btn btn-warning btn-large">Deactivate</a>
{% else %}
<a href="{% url 'activate stream' stream.pk %}" class="btn btn-success btn-large">Activate</a>
{% endif %}
<a href="javascript:;" class="reset-stream btn btn-warning btn-danger btn-large">Reset</a>
</div>
</div>
<hr>
......@@ -49,11 +53,25 @@
{% for w in stream.stream_visualization_widgets %}
<tr>
<td class="name">{{w}}</td>
<td><a href="#" class="btn btn-mini">View results</a></td>
<td><a href="{% url 'stream widget visualization' stream.pk w.pk %}" class="btn btn-mini">View results</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<script type="text/javascript">
$(function() {
$(".reset-stream").click(function() {
bootbox.confirm("Are you sure you wish to reset the stream? This means that all data that you have mined so far will be cleared.","No way!", "Yes, definitely!", function(result) {
if (result==true) {
window.location='{% url 'reset stream' stream.pk %}';
}
});
});
});
</script>
{% endblock %}
......@@ -24,7 +24,7 @@
{% if w.stream %}
{% if w.stream.active %}<span class="label label-success"><i class="icon-ok icon-white"></i> Active</span> <a href="{{w.stream.get_absolute_url}}" class="btn btn-mini"><i class="icon-wrench"></i></a>
{% else %}<span class="label label-warning"><i class="icon-remove icon-white"></i> Inactive</span> <a href="{{w.stream.get_absolute_url}}" class="btn btn-mini"><i class="icon-wrench"></i></a>{% endif %}
{% else %}<a href="#" class="btn btn-mini">Start stream mining</a>{% endif %}
{% else %}<a href="{% url 'start stream' w.pk %}" class="btn btn-mini">Start stream mining</a>{% endif %}
{% else %}<span class="label"><i class="icon-remove icon-white"></i> No streaming widgets</span>{% endif %}
</td>
<td><a href="{{w.get_absolute_url}}">Edit</a> | <a href="{{w.get_copy_url}}">Open as new</a> | <a href="javascript:;" rel="{{w.pk}}" class="delete_workflow">Delete</a> | {% if not w.public %}<a href="{% url 'make public' w.pk %}">Make public</a>{% else %}<a href="{% url 'make private' w.pk %}">Make private</a>{% endif %}</td>
......
......@@ -7,6 +7,13 @@ urlpatterns = patterns('',
url(r'^your-workflows/', 'website.views.your_workflows', name='your workflows'),
url(r'^streams/(?P<stream_id>[0-9]+)/$', 'website.views.stream', name='stream'),
url(r'^start-stream/(?P<workflow_id>[0-9]+)/$', 'website.views.start_stream', name='start stream'),
url(r'^activate-stream/(?P<stream_id>[0-9]+)/$', 'website.views.activate_stream', name='activate stream'),
url(r'^deactivate-stream/(?P<stream_id>[0-9]+)/$', 'website.views.deactivate_stream', name='deactivate stream'),
url(r'^reset-stream/(?P<stream_id>[0-9]+)/$', 'website.views.reset_stream', name='reset stream'),
url(r'^make-private/(?P<workflow_id>[0-9]+)/$', 'website.views.make_private', name='make private'),
url(r'^make-public/(?P<workflow_id>[0-9]+)/$', 'website.views.make_public', name='make public'),
......
......@@ -22,6 +22,38 @@ import os
def index(request):
return render(request, 'website/index.html')
def reset_stream(request,stream_id):
s = get_object_or_404(Stream, pk=stream_id)
if s.user != request.user:
raise Http404
s.reset()
s.save()
return redirect(s.get_absolute_url())
def deactivate_stream(request,stream_id):
s = get_object_or_404(Stream, pk=stream_id)
if s.user != request.user:
raise Http404
s.active = False
s.save()
return redirect(s.get_absolute_url())
def activate_stream(request,stream_id):
s = get_object_or_404(Stream, pk=stream_id)
if s.user != request.user:
raise Http404
s.active = True
s.save()
return redirect(s.get_absolute_url())
def start_stream(request,workflow_id):
w = get_object_or_404(Workflow, pk=workflow_id)
if w.user != request.user:
raise Http404
s = Stream(workflow=w,user=request.user,active=True)
s.save()
return redirect(s.get_absolute_url())
def stream(request,stream_id):
stream = get_object_or_404(Stream,pk=stream_id)
if stream.workflow.user != request.user:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment