summaryrefslogtreecommitdiffstats
path: root/agenda/billboardviews.py
diff options
context:
space:
mode:
Diffstat (limited to 'agenda/billboardviews.py')
-rw-r--r--agenda/billboardviews.py268
1 files changed, 268 insertions, 0 deletions
diff --git a/agenda/billboardviews.py b/agenda/billboardviews.py
new file mode 100644
index 0000000..eaea323
--- /dev/null
+++ b/agenda/billboardviews.py
@@ -0,0 +1,268 @@
+# Create your views here.
+from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
+from infopoint.agenda.models import *
+from datetime import date
+from django.http import HttpResponse, HttpResponseRedirect
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth import authenticate, login
+from django.contrib.auth.models import Group,User
+from django.contrib.comments.models import Comment
+from infopoint.agenda.templatetags import *
+from infopoint.agenda.models import Event, Attendance,Todo, Billboard,Location
+from infopoint.agenda.forms import TodoCreateForm, TodoForm
+from django.contrib.formtools.preview import FormPreview
+from django.views.generic import create_update
+from django.template import RequestContext
+from django.forms import ModelForm
+import pydot
+import unicodedata
+
+
+def event_style(event_id):
+ ev_node_style = "style='filled',fontname='Arial',fontsize='14',shape='component',URL='http://infopoint/agenda/'+str(event_id),rank='same'"
+ return ev_node_style
+
+def group_galaxymap(request,object_id):
+ this_group = Group.objects.get(pk=object_id)
+
+ group_map = pydot.Dot(this_group.name, graph_type='digraph',strict=False, suppress_disconnected=True, fontname='Arial',size="12,12",overlap="False", ranksep='0.5',ratio='auto',bgcolor="#ffffff00", packmode="clust",URL="http://infopoint/",concentrate='True' )
+ group_map.add_node(pydot.Node(this_group.name,fontname='Arial',style='filled',fontsize='26',shape='tab',fillcolor="#fd47bbff" ,URL="/agenda/map/user/"+object_id))
+ related_groups = Group.objects.all().filter(user__in=this_group.user_set.all())
+ for other_group in related_groups.exclude(pk=object_id):
+ group_map.add_node(pydot.Node(other_group.name,fillcolor='#ec8968ff',fontname='Arial',style='filled',fontsize='12',shape='tab' ,URL="/agenda/group/"+str(other_group.id)))
+ for members in other_group.user_set.all().exclude(pk=object_id):
+ group_map.add_edge(pydot.Edge(members.username,other_group.name,fontname='Arial',fontsize='8',rank="sink"))
+
+ for user_group in User.objects.all().filter(groups__in=(Group.objects.all().filter(user__in=this_group.user_set.all()))).distinct().exclude(pk=object_id):
+ group_map.add_node(pydot.Node(user_group.username,color='purple',fontsize='12',style="filled",fillcolor="#00ff005f",fontname='Arial',shape='egg',URL="/agenda/user/"+str(user_group.id),rank="same"))
+
+ for person in this_group.user_set.all():
+ group_map.add_node(pydot.Node(person.username,color='yellow',fontsize='12',style="filled",fillcolor="#f7c640ff",fontname='Arial',shape='egg',URL="/agenda/user/"+str(person.id),rank="same"))
+ group_map.add_edge(pydot.Edge(person.username,this_group.name,style='rounded',fontname='Arial'))
+
+ for one_todo in this_group.todo_set.all().exclude(done=True):
+ group_map.add_node(pydot.Node(one_todo.title,fillcolor="#f7c640ff",fontname='Arial',style='filled',fontsize='12',shape='note',URL='http://infopoint/agenda/todo/'+str(one_todo.id),rank='sink' ))
+ group_map.add_edge(pydot.Edge(one_todo.title,this_group.name,style='rounded',fontname='Arial'))
+ group_map.add_edge(pydot.Edge(one_todo.creator,one_todo.title,style='dotted',fontname='Arial',constraint='False'))
+ for comment in Comment.objects.filter(content_type=2,object_pk=this_group.id):
+ decoded = comment.comment.encode('ascii','replace')[0:12]
+ group_map.add_node(pydot.Node(str(comment.id),label=decoded,fillcolor='#8bde93ff',fontname='Arial',style='filled',fontsize='14',shape='note',URL='http://infopoint/comment/'+str(comment.id),rank='same' ))
+ group_map.add_edge(pydot.Edge(this_group.name,str(comment.id),style='rounded'))
+ group_map.add_edge(pydot.Edge(str(comment.user),str(comment.id),style='dotted'))
+ for one_event in this_group.events.all():
+ group_map.add_node(pydot.Node(one_event.title[0:20], style='filled',fontname='Arial',fontsize='14',shape='component',URL='http://infopoint/agenda/'+str(one_event.id),rank='same', fillcolor="#acce4aff"))
+ this_location = one_event.location
+ group_map.add_edge(pydot.Edge(one_event.title[0:20],this_location.title))
+ group_map.add_edge(pydot.Edge(this_group.name,this_location.title,style='dotted',fontname='Arial'))
+ group_map.add_edge(pydot.Edge(this_group.name,one_event.title[0:20],style='rounded',fontname='Arial'))
+ group_map.add_node(pydot.Node(this_location.title,fillcolor="#e399f6ff",fontname='Arial',style='filled',fontsize='8',shape='house',URL='http://infopoint/agenda/location/'+str(this_location.id)))
+ if one_event.todo.count():
+ todo_count = one_event.todo.count()
+ group_map.add_node(pydot.Node(str(todo_count)+" todos",color='black',fillcolor="#f7c640ff",fontname='Arial',style='filled',fontsize='8',shape='note',URL='http://infopoint/agenda/'+str(one_event.id),rank='sink' ))
+ group_map.add_edge(pydot.Edge(one_event.title[0:20],str(todo_count)+" todos",style='rounded',fontname='Arial'))
+ group_map.add_edge(pydot.Edge(this_group.name,one_event.title[0:20],style='rounded'))
+
+ for another_group in one_event.redes.all().exclude(pk=object_id):
+ group_map.add_edge(pydot.Edge(another_group.name,one_event.title[0:20],style='dotted',fontname='Arial'))
+
+ group_map.write_png('/var/www/media/maps/group_'+object_id+'.png', prog='dot')
+ group_map.write_cmap('/var/www/media/maps/group_'+object_id+'.map', prog='dot')
+ group_map.write_dot('/var/www/media/maps/group_'+object_id+'.dot', prog='dot')
+ return HttpResponseRedirect('/agenda/group/'+object_id)
+
+
+
+def user_galaxymap(request,object_id):
+ user = User.objects.get(pk=object_id)
+ #comments =
+
+
+ user_map = pydot.Dot(user.username, graph_type='digraph',strict=False, suppress_disconnected=True, fontname='Arial',size="11,14",overlap="False", ranksep='0.5',ratio='auto',bgcolor="#ffffff00", packmode="clust",URL="http://infopoint/",concentrate='True' )
+ user_map.add_node(pydot.Node(user.username,color='purple',fontname='Arial',style='filled',fontsize='20',shape='record' ,URL="http://infopoint/agenda/map/user/"+object_id))
+ user_events = user.events.all()
+ user_comments = user.comment_comments.all()
+ todos_created_by_user = user.todocreator.all().filter(done=False)
+ groups = pydot.Subgraph(graph_name='Groups', label='Groups',suppress_disconnected=False,style='filled',fillcolor='#00ff005d',fontname='Arial', rank='same')
+
+ user_map.add_node(pydot.Node('Todos',color='purple',fontname='Arial',style='filled',fontsize='20',shape='note' ,URL="http://infopoint/agenda/map/user/"+object_id))
+ user_map.add_edge(pydot.Edge(user.username,'Todos',style='rounded',fontname='Arial',label='location',len='1'))
+ for one_event in todos_created_by_user:
+ user_map.add_node(pydot.Node(one_event.title,fontname='Arial',style='filled',fontsize='16',shape='component',URL='http://infopoint/agenda/todo/'+str(one_event.id),rank='same' ))
+ user_map.add_edge(pydot.Edge('Todos',one_event.title,style='rounded',fontname='Arial'))
+
+ for one_event in user_events:
+ user_map.add_node(pydot.Node(str(one_event.title),color='green',fontname='Arial',style='filled',fontsize='10',shape='record',URL='http://infopoint/agenda/'+str(one_event.id)))
+ user_map.add_edge(pydot.Edge(user.username,str(one_event.title),style='rounded',fontname='Arial',label='goes to',len='1'))
+ user_map.add_edge(pydot.Edge(str(one_event.title),str(one_event.location),style='rounded',fontname='Arial',label='location',len='1'))
+ user_map.add_subgraph(groups)
+
+ user_map.write_png('/var/www/media/maps/user_'+object_id+'.png', prog='dot')
+ user_map.write_cmap('/var/www/media/maps/user_'+object_id+'.map', prog='dot')
+ map_coordinates = user_map.create_cmap( prog='dot')
+ return HttpResponseRedirect('/agenda/user/'+object_id)
+
+
+def location_galaxymap(request,object_id):
+ location = Location.places.get(pk=object_id)
+ #comments =
+ location_map = pydot.Dot(location.title, graph_type='digraph',strict=False, suppress_disconnected=False, fontname='Arial',size="12,4",overlap="False", ranksep='0.5',ratio='auto',bgcolor="#ffffff00", packmode="clust",URL="http://infopoint/", concentrate='True' )
+ location_map.add_node(pydot.Node(location.title,fontname='Arial',style='filled',fontsize='24',shape='house',fillcolor='#e399f6ff', URL='/agenda/location/'+str(object_id)))
+ events_map = pydot.Subgraph(graph_name='Events')
+ todo_map = pydot.Subgraph(graph_name='Todos')
+ groups_map = pydot.Subgraph(graph_name='Groups')
+ comments_map = pydot.Subgraph(graph_name='Comments')
+
+ for one_todo in location.todolocation.all():
+ todo_map.add_node(pydot.Node(one_todo.title[0:20],URL='/agenda/'+str(one_todo.id) ))
+ location_map.add_edge(pydot.Edge(one_todo.title[0:20],location.title))
+ location_map.add_edge(pydot.Edge(one_todo.creator,one_todo.title[0:20]))
+
+ for events in location.event_set.all():
+ events_map.add_node(pydot.Node(events.title.encode('ascii', 'ignore')[0:20],URL='/agenda/'+str(events.id) ))
+ location_map.add_edge(pydot.Edge(events.title.encode('ascii', 'ignore')[0:20],location.title))
+ for comment in Comment.objects.filter(content_type='13',object_pk=events.id):
+ comment.comment.encode('ascii', 'ignore')
+ comments_map.add_node(pydot.Node(comment.comment[0:20],URL='/comment/'+str(comment.id) ))
+ location_map.add_edge(pydot.Edge(events.title[0:20],comment.comment[0:20]))
+ location_map.add_edge(pydot.Edge(comment.user,comment.comment[0:20],constraint='False'))
+
+ for group in events.group.iterator():
+ groups_map.add_node(pydot.Node(group.group,URL='/comment/'+str(group.group_id) ))
+ location_map.add_edge(pydot.Edge(events.title,group.group[0:20]))
+
+ for todo in events.todo.all().exclude(done='True'):
+ todo.title.encode('ascii', 'ignore')
+ todo_map.add_node(pydot.Node(todo.title[0:20],URL='/agenda/todo/'+str(events.id) ))
+ location_map.add_edge(pydot.Edge(todo.title[0:20],events.title[0:20]))
+ location_map.add_edge(pydot.Edge(todo.creator,todo.title[0:20]))
+
+ for comment in Comment.objects.filter(content_type='12',object_pk=object_id):
+ comment.comment.encode('ascii', 'ignore')
+ comments_map.add_node(pydot.Node(comment.comment[0:20],URL='/comment/'+str(comment.id) ))
+ location_map.add_edge(pydot.Edge(location.title,comment.comment[0:20]))
+ location_map.add_edge(pydot.Edge(comment.user,comment.comment[0:20]))
+
+
+ for a in todo_map.node_list:
+ a.set_fontname('Arial')
+ a.set_fillcolor("#f7c640ff")
+ a.set_style('filled')
+ a.set_shape('tab')
+ for a in events_map.node_list:
+ a.set_fontname('Arial')
+ a.set_fillcolor("#acce4aff")
+ a.set_style('filled')
+ a.set_shape('component')
+
+ for a in comments_map.node_list:
+
+ a.set_fontname('Arial')
+ a.set_fillcolor("#8bde93ff")
+ a.set_style('filled')
+ a.set_shape('note')
+ location_map.add_subgraph(events_map)
+ location_map.add_subgraph(todo_map)
+ location_map.add_subgraph(groups_map)
+ location_map.add_subgraph(comments_map)
+ location_map.write_png('/var/www/media/maps/location_'+object_id+'.png', prog='dot')
+ location_map.write_cmap('/var/www/media/maps/location_'+object_id+'.map', prog='dot')
+ map_coordinates = location_map.create_cmap( prog='dot')
+ return HttpResponseRedirect('/agenda/location/'+object_id)
+
+
+
+def event_galaxy(request,object_id):
+ event = Event.calendar.get(pk=object_id)
+ event_redes = event.redes.all()
+ event_attending = event.atendees.all()
+ comments = Comment.objects.filter(content_type=13,object_pk=object_id)
+ location_comments = Comment.objects.filter(content_type=12,object_pk=event.location.id)
+ other_events_on_this_location = event.location.event_set.all()
+ other_events_attended_by_atendees = Event.events.next_events().filter(atendees__in=event.atendees.all()).distinct()
+ other_events_with_this_event_groups = Event.events.next_events().filter(redes__in=event.redes.all()).distinct()
+
+ map = pydot.Dot(event.description, graph_type='digraph',strict=False, suppress_disconnected=True, size="12,4",overlap="False", ranksep='0.5',ratio='auto',bgcolor="#ffffff00", packmode="clust",URL="http://infopoint/" )
+ events = pydot.Subgraph(graph_name='Events',label='Events',style='filled',fillcolor='lightgrey',packmode="clust")
+ comments_graph = pydot.Subgraph(graph_name='Comments',label='Comments',style='rounded',fillcolor='lightgrey')
+ map.add_node(pydot.Node(event.title,fillcolor="#fd47bbff",style='filled',fontsize='24',shape='component' ,URL="http://infopoint/agenda/"+object_id))
+ map.add_edge(pydot.Edge(event.title,event.location.title,style='rounded',label='location',len='1'))
+ map.add_node(pydot.Node(event.location.title,style='filled',fontsize='14',shape='house',fillcolor='#e399f6ff', URL='http://infopoint/agenda/location/'+str(event.location.id)))
+
+ for comment in location_comments:
+ comment.comment.encode('ascii','ignore')
+ comments_graph.add_node(pydot.Node(comment.comment[0:20],fillcolor="#8bde93ff",style='filled',fontsize='10',shape='note' ,URL="http://infopoint/admin/comments/comment/"+object_id+"/",rank="min"))
+ comments_graph.add_edge(pydot.Edge(comment.user,comment.comment[0:20],style='dotted',label='is_author',len='3'))
+ comments_graph.add_edge(pydot.Edge(event.location,comment.comment[0:20],style='rounded',len='1',rank='same' ))
+
+ for todo in event.location.todolocation.all().exclude(done=True):
+ decoded_todo = todo.title.encode('ascii','ignore')[0:20]
+ events.add_node(pydot.Node(decoded_todo,fillcolor="#f7c640ff",style='filled',fontsize='10',shape='note' ,URL="http://infopoint/agenda/todo/"+str(todo.id),rank="min"))
+ events.add_edge(pydot.Edge(decoded_todo,event.location,style='dotted',len='1'))
+
+ groups = pydot.Subgraph(graph_name='Groups', label='Groups',suppress_disconnected=False,style='filled',fillcolor='#00ff005d')
+ for todo in event.todo.all().exclude(done=True):
+ decoded_todo = todo.title.encode('ascii','ignore')[0:20]
+ events.add_node(pydot.Node(decoded_todo,fillcolor="#f7c640ff",style='filled',fontsize='10',shape='note' ,URL="http://infopoint/agenda/todo/"+str(todo.id),rank="min"))
+ events.add_edge(pydot.Edge(decoded_todo,event.title,style='dotted',len='2'))
+ events.add_edge(pydot.Edge(todo.creator,decoded_todo,style='dotted',len='2',constraint=False))
+ for location_event in event.location.event_set.all().exclude(id=object_id):
+ events.add_node(pydot.Node(location_event.title,fillcolor="#acce4aff",style='filled',fontsize='10',shape='component',URL='http://infopoint/agenda/'+str(location_event.id)))
+ events.add_edge(pydot.Edge(location_event.title,event.location,fontsize='8',rank="sink"))
+ for pixie in event.pixie.iterator():
+ comments_graph.add_edge(pydot.Edge(pixie,event.title.encode('ascii', 'ignore'),style='dotted',len='2'))
+ events.add_node(pydot.Node(pixie,fontsize='12',style="filled",fillcolor="#f7c640ff",shape='egg',URL="/agenda/user/"+str(pixie.id),rank="same"))
+ for comment in comments:
+ comment.comment.encode('ascii', 'ignore')
+ comments_graph.add_node(pydot.Node(comment.comment[0:20],fillcolor="#8bde93ff",style='filled',fontsize='10',shape='note' ,URL="http://infopoint/admin/comments/comment/"+object_id+"/",rank="min"))
+ comments_graph.add_edge(pydot.Edge(comment.user,comment.comment[0:20],style='dotted',label='is_author',len='3'))
+ comments_graph.add_edge(pydot.Edge(comment.comment[0:20],event.title,style='rounded',len='1',rank='same' ))
+
+ for person in event_attending:
+ events.add_node(pydot.Node(person.username,fontsize='12',style="filled",fillcolor="#f7c640ff",shape='egg',URL="/agenda/user/"+str(person.id),rank="same"))
+ events.add_edge(pydot.Edge(person.username,event.title,fontsize='8',rank="sink"))
+ for group in event_redes:
+ groups.add_node(pydot.Node(group.name,style="filled",fillcolor='#ec8968ff' ,shape='tab',group='groups',URL="http://infopoint/agenda/group/"+str(group.id), rank="5"))
+ events.add_edge(pydot.Edge(group.name,event.title,fontsize='8',rank="sink"))
+
+ for related_event in other_events_with_this_event_groups.exclude(pk=object_id):
+ events.add_node(pydot.Node(related_event.title,fontsize='12',style="filled",fillcolor="#acce4aff",fontname='Arial',shape='component',URL="/agenda/"+str(related_event.id),rank="same"))
+
+ for group in related_event.group.all():
+ events.add_edge(pydot.Edge(group.group,related_event.title,fontname='Arial',shape='point',fontsize='8',rank="sink"))
+ groups.add_node(pydot.Node(group.group,style="filled",fillcolor='#ec8968ff',shape='tab',group='groups',URL="http://infopoint/agenda/group/"+str(group.group_id), rank="5",fontname='Arial'))
+
+ events.add_node(pydot.Node(related_event.title,fontsize='12',style="filled",fillcolor="#acce4aff",fontname='Arial',shape='component',URL="/agenda/"+str(related_event.id),rank="same"))
+ events.add_edge(pydot.Edge(event.title,related_event.title,fontname='Arial' ,fontsize='8',style='dotted',rank='same'))
+ for user in related_event.atendees.all().distinct():
+ events.add_edge(pydot.Edge(user.username,related_event.title,fontname='Arial',label='goes to',fontsize='8',rank="sink"))
+
+
+ map.add_subgraph(comments_graph)
+ map.add_subgraph(groups)
+ map.add_subgraph(events)
+ for a in comments_graph.node_list:
+ a.set_fontname('Arial')
+ for a in events.node_list:
+ a.set_fontname('Arial')
+ for a in groups.node_list:
+ a.set_fontname('Arial')
+
+ map.write_png('/var/www/media/maps/event_'+object_id+'.png', prog='dot')
+ map.write_cmap('/var/www/media/maps/event_'+object_id+'.map', prog='dot')
+ map.write_dot('/var/www/media/maps/event_'+object_id+'.dot', prog='dot')
+ return HttpResponseRedirect('/agenda/'+object_id)
+
+def one_still_event(request,object_id,billboard_id):
+ event = Event.calendar.get(pk=object_id)
+ style = Billboard.objects.get(pk=billboard_id)
+ return render_to_response('agenda/billboard_still.html', {'event': event, 'style': style },context_instance=RequestContext(request))
+
+
+def billboard(request,billboard_id):
+ style = Billboard.objects.get(pk=billboard_id)
+ list = Event.calendar.filter(location__in=style.location.all()).distinct()|Event.calendar.filter(group__in=style.groups.all()).distinct()
+ event = list.order_by('?')[:1]
+ return render_to_response('agenda/billboard.html', { 'event': event,'list': list, 'style': style },context_instance=RequestContext(request))
+
+
+