mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-15 15:22:17 +00:00
Add recommended_user to link to the exact user class from the recommendation.
This commit is contained in:
@@ -91,6 +91,10 @@ class Recommendation(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return ('hr.views.view_application', [self.application.id])
|
return ('hr.views.view_application', [self.application.id])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def recommended_user(self):
|
||||||
|
return self.application.user
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
diff = self.recommendation_date - self.user_character.corporation_date
|
diff = self.recommendation_date - self.user_character.corporation_date
|
||||||
|
|||||||
@@ -69,14 +69,14 @@ def blacklist_values(user, level=BLACKLIST_LEVEL_NOTE):
|
|||||||
|
|
||||||
return blacklist
|
return blacklist
|
||||||
|
|
||||||
def recommendation_chain(application):
|
def recommendation_chain(application, first=True):
|
||||||
""" Returns the recommendation chain for a application (as a nested dict) """
|
""" Returns the recommendation chain for a application (as a nested dict) """
|
||||||
|
|
||||||
t = {}
|
output = {}
|
||||||
for rec in application.recommendation_set.all():
|
for rec in Recommendation.objects.filter(user__username=name):
|
||||||
try:
|
# Avoid infinite loops
|
||||||
app = Application.objects.get(character=rec.user_character, status=APPLICATION_STATUS_COMPLETED)
|
if not rec.user == rec.recommended_user:
|
||||||
t[rec.user_character.name] = recommendation_chain(app)
|
output[rec.recommended_user.username] = recommendation_chain(rec.recommended_user.username, False)
|
||||||
except Application.DoesNotExist:
|
if first:
|
||||||
t[rec.user_character.name] = {}
|
return {name: output}
|
||||||
return t
|
return output
|
||||||
|
|||||||
Reference in New Issue
Block a user