mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Switch to using __unicode__ and django's smart __str__ handling, also added permalinks for HR models
This commit is contained in:
@@ -19,9 +19,6 @@ class AuthAPIKey(models.Model):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'API Key'
|
verbose_name = 'API Key'
|
||||||
verbose_name_plural = "API Keys"
|
verbose_name_plural = "API Keys"
|
||||||
|
|||||||
27
hr/models.py
27
hr/models.py
@@ -18,6 +18,10 @@ class Application(models.Model):
|
|||||||
verbose_name="Status",
|
verbose_name="Status",
|
||||||
help_text="Current status of this application request.")
|
help_text="Current status of this application request.")
|
||||||
|
|
||||||
|
@models.permalink
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return ('hr.views.view_application', [self.id])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def blacklisted(self):
|
def blacklisted(self):
|
||||||
if len(self.blacklist_values) > 0:
|
if len(self.blacklist_values) > 0:
|
||||||
@@ -97,9 +101,6 @@ class Application(models.Model):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.character.name
|
return self.character.name
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|
||||||
|
|
||||||
class Recommendation(models.Model):
|
class Recommendation(models.Model):
|
||||||
""" User recommendation for a application """
|
""" User recommendation for a application """
|
||||||
@@ -108,12 +109,13 @@ class Recommendation(models.Model):
|
|||||||
user_character = models.ForeignKey(EVEPlayerCharacter, blank=False, verbose_name="Recommender")
|
user_character = models.ForeignKey(EVEPlayerCharacter, blank=False, verbose_name="Recommender")
|
||||||
application = models.ForeignKey(Application, blank=False, verbose_name="Recommended Application")
|
application = models.ForeignKey(Application, blank=False, verbose_name="Recommended Application")
|
||||||
|
|
||||||
|
@models.permalink
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return ('hr.views.view_application', [self.application.id])
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.user_character.name
|
return self.user_character.name
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|
||||||
|
|
||||||
class Audit(models.Model):
|
class Audit(models.Model):
|
||||||
""" Auditing information regarding a application """
|
""" Auditing information regarding a application """
|
||||||
@@ -127,6 +129,13 @@ class Audit(models.Model):
|
|||||||
help_text="Detailed event text")
|
help_text="Detailed event text")
|
||||||
date = models.DateTimeField(auto_now_add=True, verbose_name="Event Date")
|
date = models.DateTimeField(auto_now_add=True, verbose_name="Event Date")
|
||||||
|
|
||||||
|
@models.permalink
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return ('hr.views.view_application', [self.application.id])
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return u"(%s) %s: %s" % (self.get_event_display(), self.user, self.text)
|
||||||
|
|
||||||
|
|
||||||
class BlacklistSource(models.Model):
|
class BlacklistSource(models.Model):
|
||||||
""" Blacklist Source """
|
""" Blacklist Source """
|
||||||
@@ -137,9 +146,6 @@ class BlacklistSource(models.Model):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|
||||||
|
|
||||||
class Blacklist(models.Model):
|
class Blacklist(models.Model):
|
||||||
""" Blacklisted entries, stops people who match the criteria from applying """
|
""" Blacklisted entries, stops people who match the criteria from applying """
|
||||||
@@ -158,6 +164,3 @@ class Blacklist(models.Model):
|
|||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'%s: %s' % (self.get_type_display(), self.value)
|
return u'%s: %s' % (self.get_type_display(), self.value)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|||||||
@@ -73,6 +73,3 @@ class RedditAccount(models.Model):
|
|||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__unicode__()
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class SSOUser(models.Model):
|
|||||||
|
|
||||||
api_service_password = models.CharField("API Services Password", max_length=200, blank=True)
|
api_service_password = models.CharField("API Services Password", max_length=200, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __unicode__(self):
|
||||||
return self.user.__str__()
|
return self.user.__unicode__()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_user_profile(sender, instance, created, **kwargs):
|
def create_user_profile(sender, instance, created, **kwargs):
|
||||||
@@ -88,7 +88,7 @@ class Service(models.Model):
|
|||||||
api.settings = self.settings
|
api.settings = self.settings
|
||||||
return api
|
return api
|
||||||
|
|
||||||
def __str__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
@@ -139,8 +139,8 @@ class ServiceAccount(models.Model):
|
|||||||
verbose_name_plural = 'Service Accounts'
|
verbose_name_plural = 'Service Accounts'
|
||||||
ordering = ['user']
|
ordering = ['user']
|
||||||
|
|
||||||
def __str__(self):
|
def __unicode__(self):
|
||||||
return "%s: %s (%s)" % (self.service.name, self.user.username, self.service_uid)
|
return u"%s: %s (%s)" % (self.service.name, self.user.username, self.service_uid)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if self.id:
|
if self.id:
|
||||||
|
|||||||
Reference in New Issue
Block a user