Skip to content
This repository
Browse code

Only install UserProfile when User is created if Minerva is installed.

Closes issue gh-17.
  • Loading branch information...
commit db2e4048a43228fdf65b3dcd8305b70ec2f4b2db 1 parent e0f1629
Malcolm Tredinnick authored

Showing 1 changed file with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. 6  minerva/signal_handlers.py
6  minerva/signal_handlers.py
... ...
@@ -1,9 +1,15 @@
  1
+from django.contrib.contenttypes.models import ContentType
1 2
 
2 3
 def create_user_profile(sender, **kwargs):
3 4
     """
4 5
     Create an empty UserProfile whenever a new User is created.
5 6
     """
6 7
     from minerva import models
  8
+    try:
  9
+        ContentType.objects.get_by_natural_key("minerva", "userprofile")
  10
+    except ContentType.DoesNotExist:
  11
+        # Minerva app hasn't been installed yet.
  12
+        return
7 13
     if not kwargs["created"]:
8 14
         return
9 15
     models.UserProfile(student=kwargs["instance"]).save()

0 notes on commit db2e404

Please sign in to comment.
Something went wrong with that request. Please try again.