mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-15 15:22:17 +00:00
Finished work on the Blacklist function, also cleaned up some HR functions
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from hr.models import Application, Recommendation, Audit
|
from hr.models import Application, Recommendation, Audit, Blacklist
|
||||||
|
|
||||||
class ApplicationAdmin(admin.ModelAdmin):
|
class ApplicationAdmin(admin.ModelAdmin):
|
||||||
list_display = ('user', 'character', 'status', 'recommendations')
|
list_display = ('user', 'character', 'status', 'recommendations')
|
||||||
@@ -28,3 +28,8 @@ class AuditAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
admin.site.register(Audit, AuditAdmin)
|
admin.site.register(Audit, AuditAdmin)
|
||||||
|
|
||||||
|
class BlacklistAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('type', 'value', 'created_date', 'created_by')
|
||||||
|
|
||||||
|
admin.site.register(Blacklist, BlacklistAdmin)
|
||||||
|
|
||||||
|
|||||||
38
hr/models.py
38
hr/models.py
@@ -17,16 +17,12 @@ class Application(models.Model):
|
|||||||
help_text="Current status of this application request.")
|
help_text="Current status of this application request.")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status_description(self):
|
|
||||||
for choice in APPLICATION_STATUS_CHOICES:
|
|
||||||
if choice[0] == int(self.status):
|
|
||||||
return choice[1]
|
|
||||||
|
|
||||||
def blacklisted(self):
|
def blacklisted(self):
|
||||||
if len(self.blacklist_values) > 0:
|
if len(self.blacklist_values) > 0:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
def blacklist_values(self):
|
def blacklist_values(self):
|
||||||
"""
|
"""
|
||||||
Returns a list of blacklist values that apply to the application
|
Returns a list of blacklist values that apply to the application
|
||||||
@@ -35,24 +31,32 @@ class Application(models.Model):
|
|||||||
blacklist = []
|
blacklist = []
|
||||||
|
|
||||||
# Check Reddit blacklists
|
# Check Reddit blacklists
|
||||||
reddit_uids = map(lambda x: x[0].lower(), self.user.redditaccount_set.all().values_list('username'))
|
reddit_uids = self.user.redditaccount_set.all().values_list('username')
|
||||||
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_REDDIT, value__in=reddit_uids)
|
reddit = [a[0].lower() for a in reddit_uids if a and a[0]]
|
||||||
blacklist.append(objs)
|
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_REDDIT, value__in=reddit)
|
||||||
|
blacklist.extend(objs)
|
||||||
|
|
||||||
# Check Character blacklists
|
# Check Character blacklists
|
||||||
chars = map(lambda x: x[0].lower(), EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('name'))
|
chars_list = EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('name')
|
||||||
|
chars = [a[0].lower() for a in chars_list if a and a[0]]
|
||||||
|
|
||||||
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CHARACTER, value__in=chars)
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CHARACTER, value__in=chars)
|
||||||
blacklist.append(objs)
|
blacklist.extend(objs)
|
||||||
|
|
||||||
# Check Corporation blacklists
|
# Check Corporation blacklists
|
||||||
corps = map(lambda x: x[0].lower(), EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__name'))
|
corp_list = EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__name')
|
||||||
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CORPORATION, value__in=corps)
|
corps = [a[0].lower() for a in corp_list if a and a[0]]
|
||||||
blacklist.append(objs)
|
|
||||||
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_CORPORATION, value__in=corps)
|
||||||
|
blacklist.extend(objs)
|
||||||
|
|
||||||
|
# Check Alliance blacklists
|
||||||
|
alliance_list = EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__alliance__name')
|
||||||
|
alliances = [a[0].lower() for a in alliance_list if a and a[0]]
|
||||||
|
|
||||||
# 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)
|
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_ALLIANCE, value__in=alliances)
|
||||||
blacklist.append(objs)
|
blacklist.extend(objs)
|
||||||
|
|
||||||
return blacklist
|
return blacklist
|
||||||
|
|
||||||
@@ -65,7 +69,7 @@ class Application(models.Model):
|
|||||||
event.user = kwargs['user']
|
event.user = kwargs['user']
|
||||||
event.event = AUDIT_EVENT_STATUSCHANGE
|
event.event = AUDIT_EVENT_STATUSCHANGE
|
||||||
|
|
||||||
event.text = "Status changed from %s to %s" % (old_instance.status_description, self.status_description)
|
event.text = "Status changed from %s to %s" % (old_instance.get_status_display(), self.get_status_display())
|
||||||
event.save()
|
event.save()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
|
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
|
||||||
<td>{{ app.character }}</td>
|
<td>{{ app.character }}</td>
|
||||||
<td>{{ app.corporation }}</td>
|
<td>{{ app.corporation }}</td>
|
||||||
<td>{{ app.status_description }}</td>
|
<td>{{ app.get_status_display }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Applying Auth User: <a href="{% url sso.views.user_view app.user %}">{{ app.user }}</a></li>
|
<li>Applying Auth User: <a href="{% url sso.views.user_view app.user %}">{{ app.user }}</a></li>
|
||||||
<li>Applying Character: {{ app.character }} <button type="button" onclick="CCPEVE.showInfo('1377//{{ app.character.id }}')">Show In Eve</button></li>
|
<li>Applying Character: {{ app.character }} <button type="button" onclick="CCPEVE.showInfo('1377//{{ app.character.id }}')">Show In Eve</button></li>
|
||||||
<li>Application Status: <b>{{ app.status_description }}</b></li>
|
<li>Application Status: <b>{{ app.get_status_display }}</b></li>
|
||||||
|
<li>Blacklist Status: <b>{% if app.blacklisted %}<span color='red'>BLACKLISTED</span>{% else %}OK{% endif %}</b></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% ifnotequal app.status 5 %}
|
{% ifnotequal app.status 5 %}
|
||||||
@@ -24,8 +25,10 @@
|
|||||||
<a href="{% url hr.views.add_note app.id %}">Add Note</a>,
|
<a href="{% url hr.views.add_note app.id %}">Add Note</a>,
|
||||||
<a href="{% url hr.views.add_message app.id %}">Send Message to Applicant</a>,
|
<a href="{% url hr.views.add_message app.id %}">Send Message to Applicant</a>,
|
||||||
{% if app.status < 2 or app.status = 4 %}
|
{% if app.status < 2 or app.status = 4 %}
|
||||||
<a href="{% url hr.views.reject_application app.id %}">Reject Application</a>,
|
<a href="{% url hr.views.reject_application app.id %}">Reject Application</a>,
|
||||||
|
{% ifequal app.blacklisted 0 %}
|
||||||
<a href="{% url hr.views.accept_application app.id %}">Accept Application</a>,
|
<a href="{% url hr.views.accept_application app.id %}">Accept Application</a>,
|
||||||
|
{% endifequal %}
|
||||||
{% ifnotequal app.status 4 %}
|
{% ifnotequal app.status 4 %}
|
||||||
<a href="{% url hr.views.update_application app.id 4 %}">Mark as In Query</a>,
|
<a href="{% url hr.views.update_application app.id 4 %}">Mark as In Query</a>,
|
||||||
{% endifnotequal %}
|
{% endifnotequal %}
|
||||||
@@ -47,6 +50,16 @@
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if app.blacklisted %}
|
||||||
|
<h3>Blacklist Triggers</h3>
|
||||||
|
<table>
|
||||||
|
<tr><th>Blacklist Type</th><th>Blacklisted Value</th><th>Reason</th></tr>
|
||||||
|
{% for a in app.blacklist_values %}
|
||||||
|
<tr><td>{{ a.get_type_display }}</td><td>{{ a.value }}</td><td>{{ a.reason }}</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if recs %}
|
{% if recs %}
|
||||||
<h3>Recommendations</h3>
|
<h3>Recommendations</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
|
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
|
||||||
<td>{{ app.character }}</td>
|
<td>{{ app.character }}</td>
|
||||||
<td>{{ app.corporation }}</td>
|
<td>{{ app.corporation }}</td>
|
||||||
<td>{{ app.status_description }}</td>
|
<td>{{ app.get_status_display }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ soon as the recommended user submits their application your recommendation will
|
|||||||
{% for rec in recs %}
|
{% for rec in recs %}
|
||||||
<tr><td>{{ rec.user_character }}</td>
|
<tr><td>{{ rec.user_character }}</td>
|
||||||
<td>{{ rec.application }}</td>
|
<td>{{ rec.application }}</td>
|
||||||
<td>{{ rec.application.status_description }}</td>
|
<td>{{ rec.application.get_status_display }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user