Maxim Syabro avatar Maxim Syabro committed e617c3e

Updated to use with django 1.5 custom user

Comments (0)

Files changed (4)

vk_iframe/backends.py

 #coding: utf-8
 from django.contrib.auth.backends import ModelBackend
-from django.contrib.auth.models import User
 from vk_iframe.models import City, Country
 
+try:
+    from django.contrib.auth import get_user_model
+except ImportError: # django < 1.5
+    from django.contrib.auth.models import User
+else:
+    User = get_user_model()
+
+
 
 class VkontakteUserBackend(ModelBackend):
     """ Использовать вместе с vk.middleware.AuthenticationMiddleware """

vk_iframe/middleware.py

 DEFAULT_P3P_POLICY = 'IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT'
 P3P_POLICY = getattr(settings, 'VK_P3P_POLICY', DEFAULT_P3P_POLICY)
 
+
 class AuthenticationMiddleware(object):
 
     def process_request(self, request):
 
 PUBLIC_URLS = [re.compile(url) for url in getattr(settings, 'PUBLIC_URLS', [])]
 
+
 class LoginRequiredMiddleware(object):
     def process_request(self, request):
 

vk_iframe/migrations/0001_initial.py

 from south.v2 import SchemaMigration
 from django.db import models
 
+try:
+    from django.contrib.auth import get_user_model
+except ImportError: # django < 1.5
+    from django.contrib.auth.models import User
+else:
+    User = get_user_model()
+
 class Migration(SchemaMigration):
 
     def forwards(self, orm):
 
         # Adding model 'Profile'
         db.create_table('vk_iframe_profile', (
-            ('user', self.gf('annoying.fields.AutoOneToOneField')(related_name='vk_profile', unique=True, primary_key=True, to=orm['auth.User'])),
+            ('user', self.gf('annoying.fields.AutoOneToOneField')(related_name='vk_profile', unique=True, primary_key=True, to=User)),
             ('nickname', self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True)),
             ('domain', self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True)),
             ('sex', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),

vk_iframe/models.py

 #coding: utf-8
+from django.conf import settings
 from django.db import models
 from django.db.models import CharField, URLField, ForeignKey, NullBooleanField, IntegerField
-from django.contrib.auth.models import User
 from annoying.fields import AutoOneToOneField
 
+try:
+    from django.contrib.auth import get_user_model
+except ImportError: # django < 1.5
+    from django.contrib.auth.models import User
+else:
+    User = get_user_model()
+
+
 class Country(models.Model):
     title = CharField(u'Название', max_length=100, null=True, blank=True)
 
     country =       ForeignKey(Country, blank=True, null=True)
     timezone =      IntegerField(u'Часовой пояс', blank=True, null=True)
 
-    photo =         URLField(blank=True, null=True, verify_exists=False)
-    photo_medium =  URLField(blank=True, null=True, verify_exists=False)
-    photo_big =     URLField(blank=True, null=True, verify_exists=False)
-    photo_rec =     URLField(blank=True, null=True, verify_exists=False)
+    photo =         URLField(blank=True, null=True)
+    photo_medium =  URLField(blank=True, null=True)
+    photo_big =     URLField(blank=True, null=True)
+    photo_rec =     URLField(blank=True, null=True)
 
     rate =          IntegerField(u'Рейтинг', blank=True, null=True)
     has_mobile =    NullBooleanField(u'Есть сотовый', blank=True, null=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.