Commit cc556c20 authored by Janez K's avatar Janez K
Browse files

dodal appe iz django 1.3 projekta

parent cba8deeb
{% extends 'website/base.html' %}
{% block 'container' %}
{% for w in workflows %}
<section>
<div class="page-header">
<h1>{{w.name}} <small>by {{w.user}}</small></h1>
</div>
<div class="row">
<div class="span3 columns">
<h3>Try it out</h3>
<p>By clicking the button below you will create a copy of this workflow and will be able to edit it, run it or just look at it without harming the original.</p>
<a href="{{w.get_copy_url}}" class="btn launch {% if not user.is_authenticated %}must_login{% endif %}">Launch workflow!{% if w.user == user %} (Create a copy){% endif %}</a><br><br>
{% if w.user == user %}<a href="{{w.get_absolute_url}}" class="btn launch {% if not user.is_authenticated %}must_login{% endif %}" onClick="$('.launch').hide();$('.ajax-loader').show()">Edit this version</a>{% endif %}
</div>
<div class="span9 columns">
<h2>Description</h2>
<p>{{w.description}}</p>
<div class="well" style="background-color: #888; border: none; background:url('{{STATIC_URL}}website-css/grid-18px-masked.png');height:250px;">
<div style="width:370px;height:270px;margin:auto;position:relative;">
{% for widget in w.normalized_widgets %}
<img src="{{STATIC_URL}}website-images/widget-{% cycle '2' '1' '3' '4' '5' %}.png" style="max-width:30px;max-height:30px;position:absolute;left:{{ widget.norm_x }}px;top:{{ widget.norm_y }}px;">
{% endfor %}
<svg width="370px" height="270px">
{% for conn in w.unique_connections %}
<line x1="{{ conn.x1 }}" y1="{{ conn.y1 }}" x2="{{ conn.x2 }}" y2="{{ conn.y2 }}" style="stroke: black;"/>
{% endfor %}
</svg>
</div>
</div>
<h2>Try it live</h2>
<p>By clicking on the button below you will launch the workflow and be able to run it or edit it.</p>
<a href="{{w.get_copy_url}}" class="btn btn-primary btn-large launch {% if not user.is_authenticated %}must_login{% endif %}" onClick="$('.launch').hide();$('.ajax-loader').show()">Launch workflow!{% if w.user == user %} (Clicking this will create a new copy){% endif %}</a>
{% if w.user == user %}<a href="{{w.get_absolute_url}}" class="btn btn-large launch {% if not user.is_authenticated %}must_login{% endif %}" onClick="$('.launch').hide();$('.ajax-loader').show()">This is your workflow. Click here to edit it!</a>{% endif %}
<hr>
</section>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends "website/base.html" %}
{% load url from future %}
{% block 'container' %}
<div class="hero-unit">
<h1>ClowdFlows</h1>
<p>Compose and execute data mining workflows with this browser based service oriented data mining tool!</p> <p>It's clean, simple and useful!</p>
<p><a href="{% url 'the index' %}" class="btn btn-primary btn-large {% if not user.is_authenticated %}must_login{% endif %}" style="margin-right:10px;">Start working</a><a href="{% url 'existing workflows' %}" class="btn btn-large">Explore existing workflows</a></p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Work anywhere</h2>
<p>The non local nature of the application allows you to work anywhere at anytime! No installation required!</p>
<p>It's a web application, and your work is saved on the server.</p>
</div>
<div class="span4">
<h2>Absolutely free</h2>
<p>You can use the platform for free! Just register and you're good to go!</p>
</div>
<div class="span4">
<h2>Powerful workflow controls</h2>
<p>Organize your workflows with powerful tools that allow packing workflows into workflow elements and even running them in <strong>for loops</strong>.</p>
</div>
</div>
<div class="row">
<div class="span4">
<h2>Web services in workflows</h2>
<p>Use WSDL webservices as workflow components.</p>
<p>Simply enter the WSDL URL of a webservice and use them as workflow elements. Connect them with other web services or provided workflow elements. </p>
</div>
<div class="span4">
<h2>Data mining algorithms</h2>
<p>Unleash the power of data mining by using Weka's algorithms that have been exposed as WSDL web services. Construct trees, build models and experiment!</p>
</div>
<div class="span4">
<h2>Contribute and share your work</h2>
<p>Have you constructed an interesting workflow? Share it with other people, so that they may use it to create or improve their workflows!</p>
</div>
</div>
{% endblock %}
\ No newline at end of file
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
url(r'^$', 'website.views.index', name='website index'),
url(r'^existing-workflows/', 'website.views.workflows', name='existing workflows'),
url(r'^workflow/(?P<workflow_id>[0-9]+)/$', 'website.views.workflow_information', name='workflow information'),
)
\ No newline at end of file
# helperji, context stvari
from django.shortcuts import render, get_object_or_404, redirect
from django.http import Http404, HttpResponse
from django.contrib import messages
# auth fore
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login, logout
from workflows.models import Workflow
#settings
from mothra.settings import DEBUG, PROJECT_FOLDER
#ostalo
from django.template.loader import get_template
from django.template import TemplateDoesNotExist
import os
def index(request):
return render(request, 'website/index.html')
def workflow_information(request,workflow_id):
w = Workflow.objects.get(pk=workflow_id)
if not w.public:
raise Http404
min_x = 10000
min_y = 10000
max_x = 0
max_y = 0
max_width = 300
max_height = 200
normalized_values = {}
w.normalized_widgets = w.widgets.all()
w.unique_connections = []
w.pairs = []
for widget in w.normalized_widgets:
if widget.x > max_x:
max_x = widget.x
if widget.x < min_x:
min_x = widget.x
if widget.y > max_y:
max_y = widget.y
if widget.y < min_y:
min_y = widget.y
for widget in w.normalized_widgets:
x = (widget.x - min_x)*1.0
y = (widget.y - min_y)*1.0
normalized_max_x = max_x-min_x
if x == 0:
x = 1
if y == 0:
y = 1
if normalized_max_x == 0:
normalized_max_x = x*2
normalized_max_y = max_y-min_y
if normalized_max_y == 0:
normalized_max_y = y*2
widget.norm_x = (x/normalized_max_x)*max_width
widget.norm_y = (y/normalized_max_y)*max_height
normalized_values[widget.id]=(widget.norm_x,widget.norm_y)
for c in w.connections.all():
if not (c.output.widget.id,c.input.widget.id) in w.pairs:
w.pairs.append((c.output.widget.id,c.input.widget.id))
for pair in w.pairs:
conn = {}
conn['x1'] = normalized_values[pair[0]][0]+40
conn['y1'] = normalized_values[pair[0]][1]+15
conn['x2'] = normalized_values[pair[1]][0]-10
conn['y2'] = normalized_values[pair[1]][1]+15
w.unique_connections.append(conn)
return render(request, 'website/existing.html', {'workflows':[w,]})
def workflows(request):
wflows = Workflow.objects.filter(public=True)
min_x = 10000
min_y = 10000
max_x = 0
max_y = 0
max_width = 300
max_height = 200
normalized_values = {}
for w in wflows:
w.normalized_widgets = w.widgets.all()
w.unique_connections = []
w.pairs = []
for widget in w.normalized_widgets:
if widget.x > max_x:
max_x = widget.x
if widget.x < min_x:
min_x = widget.x
if widget.y > max_y:
max_y = widget.y
if widget.y < min_y:
min_y = widget.y
for widget in w.normalized_widgets:
x = (widget.x - min_x)*1.0
y = (widget.y - min_y)*1.0
normalized_max_x = max_x-min_x
if x == 0:
x = 1
if y == 0:
y = 1
if normalized_max_x == 0:
normalized_max_x = x*2
normalized_max_y = max_y-min_y
if normalized_max_y == 0:
normalized_max_y = y*2
widget.norm_x = (x/normalized_max_x)*max_width
widget.norm_y = (y/normalized_max_y)*max_height
normalized_values[widget.id]=(widget.norm_x,widget.norm_y)
for c in w.connections.all():
if not (c.output.widget.id,c.input.widget.id) in w.pairs:
w.pairs.append((c.output.widget.id,c.input.widget.id))
for pair in w.pairs:
conn = {}
conn['x1'] = normalized_values[pair[0]][0]+40
conn['y1'] = normalized_values[pair[0]][1]+15
conn['x2'] = normalized_values[pair[1]][0]-10
conn['y2'] = normalized_values[pair[1]][1]+15
w.unique_connections.append(conn)
return render(request, 'website/existing.html', {'workflows':wflows})
from workflows.models import Category, AbstractWidget, AbstractInput, AbstractOutput, AbstractOption, Workflow
from django.contrib import admin
from django.forms import TextInput, Textarea
from django.db import models
from orderable_inlines import OrderableTabularInline
class InputInline(OrderableTabularInline):
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':10})},
models.TextField: {'widget': Textarea(attrs={'rows':1, 'cols':20})},
}
orderable_field = 'order'
model = AbstractInput
class OutputInline(OrderableTabularInline):
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':10})},
models.TextField: {'widget': Textarea(attrs={'rows':1, 'cols':20})},
}
orderable_field = 'order'
model = AbstractOutput
class AbstractWidgetInline(OrderableTabularInline):
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':10})},
models.TextField: {'widget': Textarea(attrs={'rows':1, 'cols':20})},
}
orderable_field = 'order'
model = AbstractWidget
class WidgetAdmin(admin.ModelAdmin):
inlines = [
InputInline,
OutputInline,
]
list_display = ('name','category','user')
class OptionInline(admin.StackedInline):
model = AbstractOption
class InputAdmin(admin.ModelAdmin):
inlines = [ OptionInline ]
class WorkflowAdmin(admin.ModelAdmin):
list_display = ('name','user','public')
class CategoryAdmin(admin.ModelAdmin):
list_display = ('name','user')
inlines = [AbstractWidgetInline]
#admin.site.register(UserProfile)
admin.site.register(Category,CategoryAdmin)
admin.site.register(AbstractWidget,WidgetAdmin)
admin.site.register(AbstractInput,InputAdmin)
admin.site.register(Workflow, WorkflowAdmin)
#admin.site.register(AbstractOutput)
\ No newline at end of file
import orange, orngRFCons
class HarfLearner(orngRFCons.RandomForestLearner):
def __new__(cls, examples=None, agrLevel = 70, **kwds):
self = orngRFCons.RandomForestLearner.__new__(cls, **kwds)
if examples:
self.__init__(**kwds)
return self.__call__(examples, weight)
else:
return self
def __init__(self, learner=None, trees=500, attributes=None, name='HARF', rand=None, callback=None):
"""random forest learner"""
self.trees = trees
self.name = name
self.learner = learner
self.attributes = attributes
self.callback = callback
def __init__(self, input_str):
self.learner
class HarfClassifier(orngRFCons.RandomForestClassifier):
import os
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
class UnpicklableObject:
def __init__(self, init_string):
self.init_string = init_string
self.imports = []
def addimport(self,import_string):
self.imports.append(import_string)
def generate(self):
for i in self.imports:
exec(i)
return eval(self.init_string)
def __unicode__(self):
return self.init_string
def __str__(self):
return self.init_string
def __repr__(self):
return self.init_string
\ No newline at end of file
from django.shortcuts import render
def test_interaction(request,input_dict,output_dict,widget):
return render(request, 'interactions/test_interaction.html',{'widget':widget})
def filter_integers(request,input_dict,output_dict,widget):
return render(request, 'interactions/filter_integers.html',{'widget':widget,'integers':input_dict['integers']})
def noiserankview(request,input_dict,output_dict,widget):
dataset = input_dict['data']
allnoise = output_dict['allnoise']
return render(request, 'interactions/noise_rank.html',{'widget':widget,'allnoise':allnoise, 'data': dataset})
def select_attrs(request, input_dict, output_dict, widget):
import orange, Orange
data = Orange.data.Table(input_dict['data'])
d = data.domain
classes = d.class_var.name
metas = []
for m in d.getmetas().values():
metas.append(str(m.name))
attrs = {}
for a in d.attributes:
attrs[a.name] = a.varType
sorted_attrs = sorted(attrs.items())
input_dict = {'ca':classes, 'ma':metas, 'attrs':attrs, 'data':input_dict['data'],'sorted_attrs':sorted_attrs}
return render(request, 'interactions/select_attrs.html',{'widget':widget, 'input_dict':input_dict})
def select_data(request, input_dict, output_dict, widget):
import Orange
data = Orange.data.Table(input_dict['data'])
attrs = {}
for a in data.domain.variables:
values = []
try:
for v in a.values:
values.append(v)
except:
pass
attrs[a.name] = {'feature':1, 'type':str(a.var_type), 'values':values}
for a in data.domain.get_metas():
meta = data.domain.get_meta(a)
values = []
try:
for v in meta.values:
values.append(v)
except:
pass
attrs[meta.name] = {'feature':0, 'type':str(meta.var_type), 'values':values}
sorted_attrs = sorted(attrs.items())
input_dict = {'data': data, 'attrs':attrs, 'sorted_attrs':sorted_attrs}
return render(request, 'interactions/select_data.html',{'widget':widget, 'input_dict':input_dict})
def build_subgroups(request, input_dict, output_dict, widget):
import Orange
data = Orange.data.Table(input_dict['data'])
class_values = []
for v in data.domain.class_var.values:
class_values.append(v)
target = {'name':data.domain.class_var.name, 'values':class_values}
return render(request, 'interactions/build_subgroups.html', {'widget':widget, 'data':data, 'target':target})
def kepner_tregoe(request, input_dict, output_dict, widget):
attributes = [att.name for att in input_dict['data'].domain.features]
return render(request, 'interactions/kepner_tregoe.html', {'widget':widget, 'attributes':attributes})
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Output.value'
db.add_column('workflows_output', 'value', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False)
def backwards(self, orm):
# Deleting field 'Output.value'
db.delete_column('workflows_output', 'value')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'workflows.abstractinput': {
'Meta': {'object_name': 'AbstractInput'},
'default': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'parameter': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'parameter_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'inputs'", 'to': "orm['workflows.AbstractWidget']"})
},
'workflows.abstractoption': {
'Meta': {'object_name': 'AbstractOption'},
'abstract_input': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'options'", 'to': "orm['workflows.AbstractInput']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
},
'workflows.abstractoutput': {
'Meta': {'object_name': 'AbstractOutput'},
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'outputs'", 'to': "orm['workflows.AbstractWidget']"})
},
'workflows.abstractwidget': {
'Meta': {'object_name': 'AbstractWidget'},
'action': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'widgets'", 'to': "orm['workflows.Category']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'wsdl': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
},
'workflows.category': {
'Meta': {'ordering': "['name']", 'object_name': 'Category'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['workflows.Category']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
},
'workflows.connection': {
'Meta': {'object_name': 'Connection'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'input': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Input']"}),
'output': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Output']"}),
'workflow': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Workflow']"})
},
'workflows.data': {
'Meta': {'object_name': 'Data'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'value': ('django.db.models.fields.TextField', [], {})
},
'workflows.input': {
'Meta': {'object_name': 'Input'},
'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'inner_output': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'outer_input_rel'", 'null': 'True', 'to': "orm['workflows.Output']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'outer_output': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'inner_input_rel'", 'null': 'True', 'to': "orm['workflows.Output']"}),
'parameter': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'parameter_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),