1. Evan Culver
  2. django-oauth-plus

Commits

David Larlet  committed 11fa275

Remove useless managers coming from previous implementation, fixes #7, thanks @agonzalezro

  • Participants
  • Parent commits eee24ee
  • Branches default

Comments (0)

Files changed (2)

File oauth_provider/managers.py

View file
 from django.db import models
 
 
-class ConsumerManager(models.Manager):
-    def create_consumer(self, name, user=None):
-        """Shortcut to create a consumer with random key/secret."""
-        consumer, created = self.get_or_create(name=name)
-        if user is not None:
-            consumer.user = user
-        if created:
-            consumer.generate_random_codes()
-        return consumer
-    
-    _default_consumer = None
-    def get_default_consumer(self, name):
-        """Add cache if you use a default consumer."""
-        if self._default_consumer is None:
-            self._default_consumer = self.get(name=name)
-        return self._default_consumer
-        
-
-class ResourceManager(models.Manager):
-    _default_resource = None
-    def get_default_resource(self, name):
-        """Add cache if you use a default resource."""
-        if self._default_resource is None:
-            self._default_resource = self.get(name=name)
-        return self._default_resource
-        
-
 class TokenManager(models.Manager):
     def create_token(self, consumer, token_type, timestamp, resource, 
             user=None, callback=None, callback_confirmed=False):

File oauth_provider/models.py

View file
 from django.db import models
 from django.contrib.auth.models import User
 
-from managers import TokenManager, ConsumerManager, ResourceManager
+from managers import TokenManager
 from consts import KEY_SIZE, SECRET_SIZE, CONSUMER_KEY_SIZE, CONSUMER_STATES,\
                    PENDING, VERIFIER_SIZE, MAX_URL_LENGTH, OUT_OF_BAND
 from utils import check_valid_callback
     name = models.CharField(max_length=255)
     url = models.TextField(max_length=MAX_URL_LENGTH)
     is_readonly = models.BooleanField(default=True)
-    
-    objects = ResourceManager()
 
     def __unicode__(self):
         return u"Resource %s with url %s" % (self.name, self.url)
 
     status = models.SmallIntegerField(choices=CONSUMER_STATES, default=PENDING)
     user = models.ForeignKey(User, null=True, blank=True)
-
-    objects = ConsumerManager()
         
     def __unicode__(self):
         return u"Consumer %s with key %s" % (self.name, self.key)