mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
Add help text to State model Remove navbar group headings Fix registration email pluralization Group memberships on state admin page Attempt to prevent resetting of state if set on profile admin manually Embed readthedocs on help page Rename CorpStats API Index to Registration Index Default corputils view to main character's corp if available Correct Application characters listing Correct string coercion of optimers Improve readability of SRP values with intcomma Beautify tables by embeding in panels Replace slugify with py3-friendly python-slugify
123 lines
4.4 KiB
Python
Executable File
123 lines
4.4 KiB
Python
Executable File
from __future__ import unicode_literals
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
from eveonline.models import EveCharacter
|
|
from eveonline.models import EveCorporationInfo
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class ApplicationQuestion(models.Model):
|
|
title = models.CharField(max_length=254)
|
|
help_text = models.CharField(max_length=254, blank=True, null=True)
|
|
|
|
def __str__(self):
|
|
return "Question: " + self.title
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class ApplicationForm(models.Model):
|
|
questions = models.ManyToManyField(ApplicationQuestion)
|
|
corp = models.OneToOneField(EveCorporationInfo)
|
|
|
|
def __str__(self):
|
|
return str(self.corp)
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class Application(models.Model):
|
|
form = models.ForeignKey(ApplicationForm, on_delete=models.CASCADE, related_name='applications')
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='applications')
|
|
approved = models.NullBooleanField(blank=True, null=True, default=None)
|
|
reviewer = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
|
|
reviewer_character = models.ForeignKey(EveCharacter, on_delete=models.SET_NULL, blank=True, null=True)
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return str(self.user) + " Application To " + str(self.form)
|
|
|
|
class Meta:
|
|
permissions = (
|
|
('approve_application', 'Can approve applications'), ('reject_application', 'Can reject applications'),
|
|
('view_apis', 'Can view applicant APIs'),)
|
|
unique_together = ('form', 'user')
|
|
|
|
@property
|
|
def main_character(self):
|
|
return self.user.profile.main_character
|
|
|
|
@property
|
|
def characters(self):
|
|
return [o.character for o in self.user.character_ownerships.all()]
|
|
|
|
@property
|
|
def reviewer_str(self):
|
|
if self.reviewer_character:
|
|
return str(self.reviewer_character)
|
|
elif self.reviewer:
|
|
return "User " + str(self.reviewer)
|
|
else:
|
|
return None
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class ApplicationResponse(models.Model):
|
|
question = models.ForeignKey(ApplicationQuestion, on_delete=models.CASCADE)
|
|
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='responses')
|
|
answer = models.TextField()
|
|
|
|
def __str__(self):
|
|
return str(self.application) + " Answer To " + str(self.question)
|
|
|
|
class Meta:
|
|
unique_together = ('question', 'application')
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class ApplicationComment(models.Model):
|
|
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='comments')
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
text = models.TextField()
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return str(self.user) + " comment on " + str(self.application)
|
|
|
|
|
|
################
|
|
# Legacy Models
|
|
################
|
|
@python_2_unicode_compatible
|
|
class HRApplication(models.Model):
|
|
character_name = models.CharField(max_length=254, default="")
|
|
full_api_id = models.CharField(max_length=254, default="")
|
|
full_api_key = models.CharField(max_length=254, default="")
|
|
is_a_spi = models.CharField(max_length=254, default="")
|
|
about = models.TextField(default="")
|
|
extra = models.TextField(default="")
|
|
|
|
corp = models.ForeignKey(EveCorporationInfo)
|
|
user = models.ForeignKey(User)
|
|
|
|
approved_denied = models.NullBooleanField(blank=True, null=True)
|
|
reviewer_user = models.ForeignKey(User, blank=True, null=True, related_name="review_user")
|
|
reviewer_character = models.ForeignKey(EveCharacter, blank=True, null=True)
|
|
reviewer_inprogress_character = models.ForeignKey(EveCharacter, blank=True, null=True,
|
|
related_name="inprogress_character")
|
|
|
|
def __str__(self):
|
|
return self.character_name + " - Application"
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class HRApplicationComment(models.Model):
|
|
created_on = models.DateTimeField(auto_now_add=True, null=True)
|
|
comment = models.CharField(max_length=254, default="")
|
|
application = models.ForeignKey(HRApplication)
|
|
commenter_user = models.ForeignKey(User)
|
|
commenter_character = models.ForeignKey(EveCharacter)
|
|
|
|
def __str__(self):
|
|
return str(self.application.character_name) + " - Comment"
|