mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Disable recommendations for people with blacklists
This commit is contained in:
@@ -8,11 +8,13 @@
|
||||
<h3>Applications</h3>
|
||||
<p><a href="{% url hr.views.view_applications %}">View your current open applications</a><br/>
|
||||
<a href="{% url hr.views.add_application %}">Create a application</a><br/></p>
|
||||
{% if can_recommend %}
|
||||
<h3>Recommendations</h3>
|
||||
<p>
|
||||
<a href="{% url hr.views.view_recommendations %}">View your current open recommendations</a><br/>
|
||||
<a href="{% url hr.views.add_recommendation %}">Add a recommendation</a><br/>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if hrstaff %}
|
||||
<h3>HR Admin</h3>
|
||||
|
||||
@@ -21,13 +21,13 @@ def installed(value):
|
||||
return False
|
||||
|
||||
|
||||
def blacklist_values(user):
|
||||
def blacklist_values(user, level=BLACKLIST_LEVEL_NOTE):
|
||||
"""
|
||||
Returns a list of blacklist values that apply to the application
|
||||
"""
|
||||
|
||||
blacklist = []
|
||||
bl_items = Blacklist.objects.filter(models.Q(expiry_date__gt=datetime.now()) | models.Q(expiry_date=None))
|
||||
bl_items = Blacklist.objects.filter(level__lte=level, models.Q(expiry_date__gt=datetime.now()) | models.Q(expiry_date=None))
|
||||
|
||||
# Check Reddit blacklists
|
||||
if installed('reddit'):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime, timedelta
|
||||
from django.utils import simplejson
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
||||
from django.shortcuts import render_to_response, get_object_or_404, redirect
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib import messages
|
||||
@@ -10,7 +10,7 @@ from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
from django.conf import settings
|
||||
|
||||
from utils import installed
|
||||
from utils import installed, blacklist_values
|
||||
|
||||
from eve_api.models import EVEAccount, EVEPlayerCorporation, EVEPlayerCharacter
|
||||
from hr.forms import CreateRecommendationForm, CreateApplicationForm, NoteForm, BlacklistUserForm, AdminNoteForm
|
||||
@@ -64,6 +64,7 @@ def check_permissions(user, application=None):
|
||||
@login_required
|
||||
def index(request):
|
||||
hrstaff = check_permissions(request.user)
|
||||
can_recommend = len(blacklist_values(request.user, BLACKLIST_LEVEL_ADVISORY))
|
||||
return render_to_response('hr/index.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
### Application Management
|
||||
@@ -135,6 +136,11 @@ def view_recommendations(request):
|
||||
|
||||
@login_required
|
||||
def add_recommendation(request):
|
||||
""" Add a recommendation to a user's application """
|
||||
|
||||
# If the person has a blacklist, stop recommendations
|
||||
if len(blacklist_values(request.user, BLACKLIST_LEVEL_ADVISORY)):
|
||||
raise Http404
|
||||
|
||||
clsform = CreateRecommendationForm(request.user)
|
||||
if request.method == 'POST':
|
||||
|
||||
Reference in New Issue
Block a user