mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 23:02:19 +00:00
Merge branch 'master' of ssh://git@dev.dredd.it/dreddit-auth
This commit is contained in:
@@ -45,3 +45,17 @@ AUDIT_EVENT_LOOKUP = {
|
|||||||
AUDIT_EVENT_ACCEPTED: 'Accepted',
|
AUDIT_EVENT_ACCEPTED: 'Accepted',
|
||||||
AUDIT_EVENT_MESSAGE: 'Message to User',
|
AUDIT_EVENT_MESSAGE: 'Message to User',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BLACKLIST_TYPE_REDDIT = 0
|
||||||
|
BLACKLIST_TYPE_CHARACTER = 1
|
||||||
|
BLACKLIST_TYPE_CORPORATION = 2
|
||||||
|
BLACKLIST_TYPE_ALLIANCE = 3
|
||||||
|
BLACKLIST_TYPE_EMAIL = 4
|
||||||
|
|
||||||
|
BLACKLIST_TYPE_CHOICES = (
|
||||||
|
(BLACKLIST_TYPE_REDDIT, 'Reddit Account'),
|
||||||
|
(BLACKLIST_TYPE_CHARACTER, 'Character'),
|
||||||
|
(BLACKLIST_TYPE_CORPORATION, 'Corporation'),
|
||||||
|
(BLACKLIST_TYPE_ALLIANCE, 'Alliance'),
|
||||||
|
(BLACKLIST_TYPE_EMAIL, 'Email Address'),
|
||||||
|
)
|
||||||
|
|||||||
46
hr/models.py
46
hr/models.py
@@ -22,6 +22,40 @@ class Application(models.Model):
|
|||||||
if choice[0] == int(self.status):
|
if choice[0] == int(self.status):
|
||||||
return choice[1]
|
return choice[1]
|
||||||
|
|
||||||
|
def blacklisted(self):
|
||||||
|
if len(self.blacklist_values) > 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def blacklist_values(self):
|
||||||
|
"""
|
||||||
|
Returns a list of blacklist values that apply to the application
|
||||||
|
"""
|
||||||
|
|
||||||
|
blacklist = []
|
||||||
|
|
||||||
|
# Check Reddit blacklists
|
||||||
|
reddit_uids = map(lambda x: x[0].lower(), self.user.redditaccount_set.all().values_list('username'))
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_REDDIT, value__in=reddit_uids)
|
||||||
|
blacklist.append(objs)
|
||||||
|
|
||||||
|
# Check Character blacklists
|
||||||
|
chars = map(lambda x: x[0].lower(), EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('name'))
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CHARACTER, value__in=chars)
|
||||||
|
blacklist.append(objs)
|
||||||
|
|
||||||
|
# Check Corporation blacklists
|
||||||
|
corps = map(lambda x: x[0].lower(), EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__name'))
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CORPORATION, value__in=corps)
|
||||||
|
blacklist.append(objs)
|
||||||
|
|
||||||
|
# Check Character blacklists
|
||||||
|
alliances = map(lambda x: x[0].lower(), EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__alliance__name'))
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_ALLIANCE, value__in=alliances)
|
||||||
|
blacklist.append(objs)
|
||||||
|
|
||||||
|
return blacklist
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
old_instance = Application.objects.get(id=self.id)
|
old_instance = Application.objects.get(id=self.id)
|
||||||
@@ -70,3 +104,15 @@ class Audit(models.Model):
|
|||||||
|
|
||||||
def event_description(self):
|
def event_description(self):
|
||||||
return AUDIT_EVENT_LOOKUP[self.event]
|
return AUDIT_EVENT_LOOKUP[self.event]
|
||||||
|
|
||||||
|
class Blacklist(models.Model):
|
||||||
|
type = models.IntegerField(choices=BLACKLIST_TYPE_CHOICES,
|
||||||
|
verbose_name="Blacklisted Type",
|
||||||
|
help_text="Type of entity to be blacklisted")
|
||||||
|
value = models.CharField("Blacklisted Value", max_length=255, blank=False)
|
||||||
|
reason = models.TextField(blank=False, verbose_name="Reason",
|
||||||
|
help_text="Reason that the entity was blacklisted")
|
||||||
|
|
||||||
|
created_date = models.DateTimeField(auto_now_add=True, verbose_name="Created Date")
|
||||||
|
created_by = models.ForeignKey(User, blank=False, verbose_name="Created By")
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
'django.contrib.humanize',
|
'django.contrib.humanize',
|
||||||
'django_evolution',
|
|
||||||
'piston',
|
'piston',
|
||||||
'registration',
|
'registration',
|
||||||
'eve_proxy',
|
'eve_proxy',
|
||||||
|
|||||||
Reference in New Issue
Block a user