Basic group list
authorArthur Darcet <arthur.darcet@m4x.org>
Sat, 2 Feb 2013 13:36:23 +0000 (14:36 +0100)
committerArthur Darcet <arthur.darcet@m4x.org>
Sat, 2 Feb 2013 13:36:23 +0000 (14:36 +0100)
xnet/group/models.py
xnet/group/urls.py [new file with mode: 0644]
xnet/group/views.py [new file with mode: 0644]
xnet/site/static/css/groups.css [new file with mode: 0644]
xnet/templates/base.html
xnet/templates/groups/index.html [new file with mode: 0644]
xnet/urls.py

index b544387..a2c273d 100644 (file)
@@ -38,7 +38,7 @@ class Group(models.Model):
     kind = models.CharField(max_length=10, choices=KIND_CHOICES, verbose_name=_(u"kind"))
     domain = models.CharField(max_length=20, choices=DOMAIN_CHOICES, verbose_name=_(u"domain"))
 
-    dns = models.CharField(max_length=128, verbose_name=_(u"dns domain"), blank=True, unique=True)
+    dns = models.CharField(max_length=128, verbose_name=_(u"dns domain"), blank=True)
 
     class Meta:
         verbose_name = _(u"group")
diff --git a/xnet/group/urls.py b/xnet/group/urls.py
new file mode 100644 (file)
index 0000000..5a16503
--- /dev/null
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import patterns, url
+
+
+urlpatterns = patterns(
+    'xnet.group.views',
+    url(r'^$', 'index', name='index'),
+    url(r'^view/([0-9]+)$', 'view', name='view'),
+)
diff --git a/xnet/group/views.py b/xnet/group/views.py
new file mode 100644 (file)
index 0000000..8cc4072
--- /dev/null
@@ -0,0 +1,11 @@
+from django.contrib import messages
+from django.shortcuts import render
+
+from xnet.group.models import Group
+
+
+def index(request):
+    return render(request, 'groups/index.html', {'groups': Group.objects.order_by('kind')})
+
+def view(request):
+    pass
diff --git a/xnet/site/static/css/groups.css b/xnet/site/static/css/groups.css
new file mode 100644 (file)
index 0000000..5ca99d8
--- /dev/null
@@ -0,0 +1,15 @@
+.group_list {
+    float: left;
+    border: solid 1px black;
+    border-radius: 5px;
+    background-color: white;
+    margin: 1%;
+    width: 22%;
+}
+.group_list h3 {
+    margin: 0 10px 0 10px;
+    font-size: medium;
+}
+.group_list li {
+    list-style: none;
+}
index 8b0257f..69aa45d 100644 (file)
@@ -11,6 +11,7 @@
         <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
         <![endif]-->
         <link href="{% static 'css/common.css' %}" rel="stylesheet">
+        {% block css %}{% endblock %}
     </head>
     <body>
     {% block body %}
@@ -27,9 +28,9 @@
                 </p>
                 <div class="nav-collapse collapse">
                     <ul class="nav">
-                        <li{% if top == 'blah' %} class="active"{% endif %}>
-                            <a href="#">
-                                {% trans "blah" %}
+                        <li{% if top == 'groups' %} class="active"{% endif %}>
+                            <a href="/groups">
+                                {% trans "Groupes" %}
                             </a>
                         </li>
                         <li{% if top == 'blih' %} class="active"{% endif %}>
diff --git a/xnet/templates/groups/index.html b/xnet/templates/groups/index.html
new file mode 100644 (file)
index 0000000..9001ee8
--- /dev/null
@@ -0,0 +1,37 @@
+{% extends "base.html" %}
+{% load static %}
+
+{% block css %}
+    {{ block.super }}
+    <link href="{% static 'css/groups.css' %}" rel="stylesheet">
+{% endblock %}
+{% block js %}
+    <script type="text/javascript">
+        $('.search-field').keyup(function(){
+            var children = $('#' + $(this).data('target') + ' ul').children();
+            var search = $(this).val();
+            console.log(children);
+            console.log($(this).data('target'));
+            for(var i=0; i<children.length; i++)
+                if($(children[i]).html().match(new RegExp(search, 'i')) == null)
+                    $(children[i]).hide();
+                else
+                    $(children[i]).show();
+        });
+    </script>
+{% endblock %}
+
+{% block content %}
+{% regroup groups by get_kind_display as group_list %}
+{% for group in group_list %}
+<div class="group_list" id="{{ group.grouper }}_type">
+    <h3>{{ group.grouper }}</h3>
+    <input type="text" class="search-field" data-target="{{ group.grouper }}_type" />
+    <ul>
+        {% for item in group.list %}
+          <li><a href="{% url 'groups:view' item.pk %}">{{ item }}</a></li>
+        {% endfor %}
+    </ul>
+</div>
+{% endfor %}
+{% endblock %}
index 89a94dc..8c4236e 100644 (file)
@@ -11,6 +11,6 @@ admin.site.login_template = 'xnet/admin_login.html'
 urlpatterns = patterns('',
     url(r'^$', 'xnet.site.views.home', name='home'),
     url(r'^xorgauth/', authgroupex_view.login_view, name='xorgauth'),
-
+    url(r'^groups/', include('xnet.group.urls', namespace='groups')),
     url(r'^admin/', include(admin.site.urls)),
 )