Finished work on the Blacklist function, also cleaned up some HR functions

This commit is contained in:
2010-07-05 12:09:55 +01:00
parent 4a3b801185
commit fd8e9451f8
6 changed files with 45 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
from django.contrib import admin
from django.contrib.auth.models import User
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):
list_display = ('user', 'character', 'status', 'recommendations')
@@ -28,3 +28,8 @@ class AuditAdmin(admin.ModelAdmin):
admin.site.register(Audit, AuditAdmin)
class BlacklistAdmin(admin.ModelAdmin):
list_display = ('type', 'value', 'created_date', 'created_by')
admin.site.register(Blacklist, BlacklistAdmin)

View File

@@ -17,16 +17,12 @@ class Application(models.Model):
help_text="Current status of this application request.")
@property
def status_description(self):
for choice in APPLICATION_STATUS_CHOICES:
if choice[0] == int(self.status):
return choice[1]
def blacklisted(self):
if len(self.blacklist_values) > 0:
return True
return False
@property
def blacklist_values(self):
"""
Returns a list of blacklist values that apply to the application
@@ -35,24 +31,32 @@ class Application(models.Model):
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)
reddit_uids = self.user.redditaccount_set.all().values_list('username')
reddit = [a[0].lower() for a in reddit_uids if a and a[0]]
objs = Blacklist.objects.filter(type=BLACKLIST_TYPE_REDDIT, value__in=reddit)
blacklist.extend(objs)
# 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)
blacklist.append(objs)
blacklist.extend(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)
corp_list = EVEPlayerCharacter.objects.filter(eveaccount__user=self.user).values_list('corporation__name')
corps = [a[0].lower() for a in corp_list if a and a[0]]
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)
blacklist.append(objs)
blacklist.extend(objs)
return blacklist
@@ -65,7 +69,7 @@ class Application(models.Model):
event.user = kwargs['user']
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()
except:
pass

View File

@@ -17,7 +17,7 @@
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
<td>{{ app.character }}</td>
<td>{{ app.corporation }}</td>
<td>{{ app.status_description }}</td>
<td>{{ app.get_status_display }}</td>
</tr>
{% endfor %}
</table>

View File

@@ -11,7 +11,8 @@
<ul>
<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>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>
{% ifnotequal app.status 5 %}
@@ -24,8 +25,10 @@
<a href="{% url hr.views.add_note app.id %}">Add Note</a>,&nbsp;
<a href="{% url hr.views.add_message app.id %}">Send Message to Applicant</a>,
{% if app.status < 2 or app.status = 4 %}
<a href="{% url hr.views.reject_application app.id %}">Reject Application</a>,&nbsp;
<a href="{% url hr.views.reject_application app.id %}">Reject Application</a>,&nbsp;
{% ifequal app.blacklisted 0 %}
<a href="{% url hr.views.accept_application app.id %}">Accept Application</a>,&nbsp;
{% endifequal %}
{% ifnotequal app.status 4 %}
<a href="{% url hr.views.update_application app.id 4 %}">Mark as In Query</a>,&nbsp;
{% endifnotequal %}
@@ -47,6 +50,16 @@
</table>
{% 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 %}
<h3>Recommendations</h3>
<ul>

View File

@@ -11,7 +11,7 @@
<tr><td><a href="{% url hr.views.view_application app.id %}">{{ app.id }}</a></td>
<td>{{ app.character }}</td>
<td>{{ app.corporation }}</td>
<td>{{ app.status_description }}</td>
<td>{{ app.get_status_display }}</td>
</tr>
{% endfor %}
</table>

View File

@@ -14,7 +14,7 @@ soon as the recommended user submits their application your recommendation will
{% for rec in recs %}
<tr><td>{{ rec.user_character }}</td>
<td>{{ rec.application }}</td>
<td>{{ rec.application.status_description }}</td>
<td>{{ rec.application.get_status_display }}</td>
</tr>
</tbody>
{% endfor %}