def authenticate(self, username=None, password=None): logger.info('{0} {1}'.format(self, username)) try: user = User.objects.get(username=username) if user.is_superuser: if user.check_password(password): return user else: logger.error('SuperUser access {0} {1}'.format( self, username)) return None try: if user.runneruser: logger.info( 'RunnerUser:{0} current site:{1} user site:{2}'.format( username, the_site(), user.runneruser.site.id)) if the_site() == user.runneruser.site.id: if user.check_password(password): return user except: logger.error('RunnerUser access {0} {1}'.format( self, username)) return None except User.DoesNotExist: logger.error('User Not Found {0} {1}'.format(self, username)) return None
def authenticate(self, username=None, password=None): logger.info('{0} {1}'.format(self, username)) try: user = User.objects.get(username=username) if user.is_superuser: if user.check_password(password): return user else: logger.error('SuperUser access {0} {1}'.format(self, username)) return None try: if user.runneruser: logger.info('RunnerUser:{0} current site:{1} user site:{2}'. format(username, the_site(), user.runneruser.site.id)) if the_site() == user.runneruser.site.id: if user.check_password(password): return user except: logger.error('RunnerUser access {0} {1}'.format(self, username)) return None except User.DoesNotExist: logger.error('User Not Found {0} {1}'.format(self, username)) return None
class RunnerModel(models.Model): """ TODO: Doc """ siteid = models.ForeignKey(Site, default=the_site()) syncinfo = models.OneToOneField(RunnerSync, null=True, blank=True, default=None,) class Meta: abstract = True def __str__(self): if self.siteid: return '(site %s)' % self.siteid.id return '' def get_siteid(self): if self.siteid: return '%s' % self.siteid.id return '' get_siteid.allow_tags = True get_siteid.short_description = "SiteId" def get_admin_url(self): return reverse('admin:{0}_{1}_change'.format(self._meta.app_label, self._meta.module_name), args=(self.pk,))
def doit(): workdate = datenow() ret = {'info': '(site %s) Successfully Debug'%the_site(), 'error':'', 'date':workdate.strftime(DATE_FORMAT)} logger.info(ret) return ret