Commits

Mario César Señoranis Ayala  committed 289da93

work in pogress

  • Participants
  • Parent commits 90a871e

Comments (0)

Files changed (12)

File designer/models.py

     def __unicode__(self):
         return unicode(self.name)
 
+    @models.permalink
+    def get_absolute_url(self):
+        return ('project_detail', [str(self.id)])
 
 class Diagram(models.Model):
     name = models.CharField(max_length=140)
 	    
     def __unicode__(self):
         return unicode(self.name)
+
+    @models.permalink
+    def get_absolute_url(self):
+        return ('diagram_detail', [str(self.id)])
+

File designer/views.py

 
 from django.views.generic.list import ListView
 from django.views.generic.detail import DetailView
+from django.views.generic.edit import UpdateView
 
 from pizarrauml.designer.models import Project, Diagram
 
 class ProjectDetail(DetailView):
     model = Project
 
-class DiagramDetail(ListView):
+class ProjectEdit(UpdateView):
+    model = Project
+
+class DiagramDetail(DetailView):
     model = Diagram
 
-
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3', 
-        'NAME': os.path.join(VAR_PATH, 'db/transparencia.db'),                      # Or path to database file if using sqlite3.
+        'NAME': os.path.join(VAR_PATH, 'db/pizarra.db'),                      # Or path to database file if using sqlite3.
         'USER': '',                      # Not used with sqlite3.
         'PASSWORD': '',                  # Not used with sqlite3.
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
     }
 }
 
+INTERNAL_IPS = ('127.0.0.1',)
+
 # Local time zone for this installation. Choices can be found here:
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 # although not all choices may be available on all operating systems.
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
 )
 
 ROOT_URLCONF = 'pizarrauml.urls'
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
-    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
-    # Uncomment the next line to enable admin documentation:
     'django.contrib.admindocs',
+
     'pizarrauml.core',
     'pizarrauml.designer',
+    'debug_toolbar',
     'django_socketio',
 )
 
 }
 
 LOGIN_REDIRECT_URL = '/'
+
+
+DEBUG_TOOLBAR_CONFIG = {
+    'INTERCEPT_REDIRECTS': False,
+    'HIDE_DJANGO_SQL': True,
+}
+
+

File templates/base.html

     <!--[if lt IE 9]>
     <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]--> 
-    {% load socketio_tags %}
-    {% socketio %}
-    <script>
-$(function() {
-	function new_alert(msg) {
-		var custom_alert = $('<div class="alert"><a class="close" data-dismiss="alert">×</a><span></span></div>');
-		custom_alert.find('span').text(msg);
-		$('#content').prepend(custom_alert);
-	}
-
-        var socket = new io.Socket();
-        socket.connect();
-	socket.on('connect', function() {
-	    console.log('Socket conectado');
-	    socket.subscribe('avisos');
-	});
-        socket.on('message', function(data) {
-            console.log('se recibio un mensaje, con el contenido', data);
-	    new_alert(data.texto);	    
-	});
-});
-    </script>
-
 
   </head> 
   <body> 
     <div class="navbar navbar-fixed-top"> 
       <div class="navbar-inner"> 
-        <div class="container-fluid"> 
-          <ul class="nav"> 
-            <li><a href="#">Mi cuenta</a></li> 
-            <li><a href="#">Proyectos</a></li>
-            <li><a href="#">Grupos</a></li>  
+        <div class="container"> 
+          <ul class="nav pull-left"> 
+             <li><a href="/">Inicio</a></li>
+          </ul>
+          <ul class="nav pull-right"> 
             
             {% if user.is_authenticated %}
              <li><a href="/logout">Salir</a></li>
-             <li><a>Bienvenido {{user.get_full_name}}</a></li>
+	     <li></li>
+             <li><a>Bienvenido <strong>{{user}}</strong></a></li>
             {% else %}            
              <li><a href="/login">Ingresar</a></li>                            
             {% endif %}
       </div> 
     </div> 
  
-    <div class="container-fluid" id="contencontentt"> 
-      <div class="row-fluid"> 
-        <div class="span3"> 
-          <div class="well sidebar-nav"> 
-            <ul class="nav nav-list"> 
-              <li class="nav-header">Diagramas</li> 
-              <li><a href="">Diagrama de Secuencia</a></li> 
-            </ul> 
-          </div> 
-        </div> 
-        <div class="span9"> 
-          
-    {% block content%}
-    {% endblock %}
- 
-        </div> 
-      </div><!--/row-fluid--> 
-    </div> <!--/container-fluid--> 
+    <div class="container">
+      <div class="row"> 
+        <div class="span12">{% block content%} {% endblock %}</div> 
+      </div>
+    </div> 
   </body> 
 </html> 

File templates/chat/join.html

+<html>
+<head>
+<title>Entrar a una sala</title>
+</head>
+<body>
+
+<form action="" method="POST">{% csrf_token %}
+{{form.as_p}}
+<hr>
+<button type="submit">Entrar</button>
+</form>
+
+</body>
+</html>
+ 

File templates/chat/room.html

+<html>
+<head>
+<title>#{{name}}</title>
+<script src="{{STATIC_URL}}js/jquery.min.js"></script>
+{% load socketio_tags %}
+{% socketio %}
+<script>
+$(function() {
+        var socket = new io.Socket();
+        socket.connect();
+	socket.on('connect', function() {
+	    console.log('Socket conectado');
+	    socket.subscribe('room-{{name}}');
+	});
+        socket.on('message', function(data) {
+            console.log(data);
+	});
+
+	// jquery, tienes que capturar el post del form,
+        // y ejecutar in socket.send
+
+});
+</script>
+</head>
+<body>
+
+<ul id="chat-room">
+<li></li>
+</ul>
+
+<form action="" method="POST">
+
+</form>
+
+</body>
+</html>

File templates/designer/diagram_detail.html

+{% extends 'base.html' %}
+
+{% block content %}
+
+<h2>{{object.name}}</h2>
+
+{% endblock %}

File templates/designer/project_detail.html

+{% extends 'base.html' %}
+
+{% block content %}
+
+<h1>{{project.name}}</h1>
+<p>
+Propietario: <strong>{{project.owner}}</strong>
+</p>
+
+<p>
+  <h3>Grupos autorizados a editar:</h3>
+  <ul>
+  {% for group in project.groups.all %}
+    <li>
+	{{group.name}} 
+    </li>
+  {% endfor %}
+  </ul>
+</p>
+<hr>
+
+<ul class='thumbnails'>
+{% for diagram in project.diagram_set.all %}
+<li class='span3'>
+<div class='thumbnail'>
+<div class='caption'>
+<h5>{{diagram.name}}</h5>
+<a class='btn' href='{{diagram.get_absolute_url}}'><i class='icon-pencil'></i>Diseñador</a>
+{% if user == project.owner %}
+<a class='btn btn-success' href='{{diagram.get_absolute_url}}'><i class='icon-cog icon-white'></i>Editar</a>
+{% endif %}
+</div>
+</div>
+</li>
+{% endfor %}
+</ul>
+
+{% endblock %}

File templates/designer/project_form.html

+{% extends 'base.html' %}
+
+{% block content %}
+
+<form action='' method='POST'>{% csrf_token %}
+{{form.as_p}}
+<button type='submit'>Grabar</button>
+</form>
+
+{% endblock %}

File templates/designer/project_list.html

 {% block content %}
 <h1>Proyectos</h1>
 
-<table class="table table-bordered table-condensed">
-<thead>
-  <tr>
-    <th>Nombre del proyecto</th>
-    <th>Propietario</th>
-    <th>Grupo asignado</th>
-  </tr>
-</thead>
-<tbody>
-  {% for project in projects %}
-  <tr>
-    <td>{{project.name}}</td>
-    <td>{{project.owner.username}}</td>
-    <td>{{project.groups.objects.all }}</td>
-  </tr>
-  {% endfor %}
-</tbody>
+<ul class="thumbnails" style="margin-top: 2em">
+{% for project in project_list %}
+<li class="span3">
+<div class="thumbnail">
+	<h2>{{project.name}}</h2>
+	<p><i class='icon-user'></i>{{project.owner.username}}</p>
+	<a href="{% url project_detail project.id %}" class="btn btn-primary">Ver</a>
+	{% if user == project.owner %}
+	<a href="{% url project_edit project.id %}" class="btn btn-success"><i class='icon-cog icon-white'></i> Editar</a>
+	{% endif %}
+	{% if user.is_authenticated and user != project.owner %}
+	<a href="{% url project_detail project.id %}" class="btn"><i class='btn-heart'></i>Unirse</a>
+	{% endif %}
+</div>
+</li>
+{% endfor %}
+</ul>
 
 
-</table>
 
 
 {% endblock %}
 admin.autodiscover()
 
 urlpatterns = patterns('',
-    # Examples:
-    url(r'^$', 'pizarrauml.views.home', name='home'),
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     url(r'^admin/', include(admin.site.urls)),
     url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
     url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),
-
-    url(r'projects/', designer_views.ProjectList.as_view()),
-    url(r'projects/(?P<pk>\d+)/', designer_views.ProjectDetail.as_view()),
-    url(r'diagrams/(?P<pk>\d+)/', designer_views.DiagramDetail.as_view()),
-
-    url(r'^test/', 'pizarrauml.views.test'),
-
+    url(r'^p/(?P<pk>\d+)/$', designer_views.ProjectDetail.as_view(), name='project_detail'),
+    url(r'^p/(?P<pk>\d+)/edit/$', designer_views.ProjectEdit.as_view(), name='project_edit'),
+    url(r'^d/(?P<pk>\d+)/$', designer_views.DiagramDetail.as_view(), name='diagram_detail'),
+    url(r'^$', designer_views.ProjectList.as_view(), name='home'),
     url(r'', include('django_socketio.urls')),
 )
+
 urlpatterns += patterns('django.contrib.staticfiles.views',
     url(r'^static/(?P<path>.*)$', 'serve'),
 )

File views.py

-from django.shortcuts import render
-from django.http import HttpResponse
-from pizarrauml.designer.models import Project
-from django_socketio import broadcast
-
-def home(request):
-    projects = []
-
-    if request.user.is_authenticated():
-        projects = Project.objects.filter(owner=request.user)
-
-    return render(request,'home.html', {'projects': projects,})
-
-def login(request):
-    return render(request,'login.html', {})
-
-def test(request):
-    broadcast({'texto': 'Importante! atencion! Terremoto en CHILE!!!'})
-    return HttpResponse('OK!!')
-
-def projectlist(request):
-    return render(request,'projectlist.html', {})
-
-def newproject(request):
-    return render(request,'newproject.html', {})
-
-def project(request):
-    return render(request,'project.html', {})