Rappels: liste seulement chercheur, et ajout permission
authorPA Parent <paparent@paparent.me>
Fri, 7 Oct 2011 19:54:19 +0000 (15:54 -0400)
committerPA Parent <paparent@paparent.me>
Fri, 7 Oct 2011 19:54:19 +0000 (15:54 -0400)
auf_savoirs_en_partage/rappels/migrations/0002_perm_rappels.py [new file with mode: 0644]
auf_savoirs_en_partage/rappels/views.py

diff --git a/auf_savoirs_en_partage/rappels/migrations/0002_perm_rappels.py b/auf_savoirs_en_partage/rappels/migrations/0002_perm_rappels.py
new file mode 100644 (file)
index 0000000..ad49c7b
--- /dev/null
@@ -0,0 +1,79 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+class Migration(DataMigration):
+
+    def forwards(self, orm):
+        ct, created = orm['contenttypes.ContentType'].objects.get_or_create(model='', app_label='rappels', name='rappels')
+        ct.save()
+        p, created = orm['auth.Permission'].objects.get_or_create(codename='rappels', content_type=ct, name='rappels')
+        p.save()
+
+
+    def backwards(self, orm):
+        ct, created = orm['contenttypes.ContentType'].objects.get_or_create(model='', app_label='rappels', name='rappels')
+        p,created = orm['auth.Permission'].objects.get_or_create(codename='rappels', content_type=ct, name='rappels')
+        ct.delete()
+        p.delete()
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'unique': 'True'}),
+            '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', [], {'max_length': '30', 'unique': 'True'})
+        },
+        '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'})
+        },
+        'rappels.rappel': {
+            'Meta': {'object_name': 'Rappel'},
+            'contenu': ('django.db.models.fields.TextField', [], {}),
+            'date_cible': ('django.db.models.fields.DateField', [], {}),
+            'date_creation': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'date_limite': ('django.db.models.fields.DateField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'sujet': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'user_creation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'rappels.rappeluser': {
+            'Meta': {'object_name': 'RappelUser'},
+            'date_envoi': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'rappel': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['rappels.Rappel']"}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        }
+    }
+
+    complete_apps = ['rappels']
index 4245fa7..3d01825 100644 (file)
@@ -7,10 +7,10 @@ from django.contrib.auth.decorators import permission_required
 from django.contrib.auth.models import User
 
 
-@permission_required('savoirs.statistiques')
+@permission_required('rappels.rappels')
 def admin_rappels(request):
 
-    chercheurs = User.objects.extra(select={'year': "EXTRACT(year FROM last_login)", 'month': "EXTRACT(month FROM last_login)"}).values('year', 'month').annotate(total=Count('username')).order_by('year', 'month')
+    chercheurs = User.objects.exclude(chercheur__exact=None).extra(select={'year': "EXTRACT(year FROM last_login)", 'month': "EXTRACT(month FROM last_login)"}).values('year', 'month').annotate(total=Count('username')).order_by('year', 'month')
 
     return render_to_response('admin/rappels/rappels.html', {
         'chercheurs': chercheurs