summaryrefslogtreecommitdiff
path: root/sublab_project/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'sublab_project/accounts')
-rw-r--r--sublab_project/accounts/__init__.py0
-rw-r--r--sublab_project/accounts/models.py21
-rw-r--r--sublab_project/accounts/tests.py16
-rw-r--r--sublab_project/accounts/views.py1
4 files changed, 38 insertions, 0 deletions
diff --git a/sublab_project/accounts/__init__.py b/sublab_project/accounts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sublab_project/accounts/__init__.py
diff --git a/sublab_project/accounts/models.py b/sublab_project/accounts/models.py
new file mode 100644
index 0000000..821bed3
--- /dev/null
+++ b/sublab_project/accounts/models.py
@@ -0,0 +1,21 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+from django.db.models.signals import post_save
+from django_auth_ldap.backend import populate_user
+
+class UserProfile(models.Model):
+ """A (dummy) user profile, needed for LDAP
+ """
+ user = models.OneToOneField(User)
+
+
+def create_user_profile(sender, instance, created, **kwargs):
+ if created:
+ UserProfile.objects.create(user=instance)
+post_save.connect(create_user_profile, sender=User)
+
+
+def set_user_as_staff(sender, user, ldap_user, **kwargs):
+ user.is_staff = True # Every LDAP user should be able to use admin
+populate_user.connect(set_user_as_staff)
diff --git a/sublab_project/accounts/tests.py b/sublab_project/accounts/tests.py
new file mode 100644
index 0000000..501deb7
--- /dev/null
+++ b/sublab_project/accounts/tests.py
@@ -0,0 +1,16 @@
+"""
+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)
diff --git a/sublab_project/accounts/views.py b/sublab_project/accounts/views.py
new file mode 100644
index 0000000..60f00ef
--- /dev/null
+++ b/sublab_project/accounts/views.py
@@ -0,0 +1 @@
+# Create your views here.