From 7a9bb0c84b3c7fa2722e81e885f6a48e6636e981 Mon Sep 17 00:00:00 2001 From: Adarnof Date: Fri, 23 Feb 2018 12:45:23 -0500 Subject: [PATCH] Centralize portrait/logo URL creation. --- .../templates/authentication/dashboard.html | 5 ++-- allianceauth/corputils/models.py | 2 +- .../templates/corputils/corpstats.html | 12 ++++++--- allianceauth/eveonline/models.py | 27 +++++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/allianceauth/authentication/templates/authentication/dashboard.html b/allianceauth/authentication/templates/authentication/dashboard.html index 19fd67fe..6fe28db3 100644 --- a/allianceauth/authentication/templates/authentication/dashboard.html +++ b/allianceauth/authentication/templates/authentication/dashboard.html @@ -21,7 +21,7 @@ @@ -102,8 +102,7 @@ {% for ownership in request.user.character_ownerships.all %} {% with ownership.character as char %} - diff --git a/allianceauth/corputils/models.py b/allianceauth/corputils/models.py index 2938c535..42251a80 100644 --- a/allianceauth/corputils/models.py +++ b/allianceauth/corputils/models.py @@ -182,4 +182,4 @@ class CorpMember(models.Model): if item.startswith('portrait_url_'): size = item.strip('portrait_url_') return self.portrait_url(size) - return super(CorpMember, self).__getattr__(item) \ No newline at end of file + return self.__getattribute__(item) \ No newline at end of file diff --git a/allianceauth/corputils/templates/corputils/corpstats.html b/allianceauth/corputils/templates/corputils/corpstats.html index f0e78ce3..7cec62f9 100644 --- a/allianceauth/corputils/templates/corputils/corpstats.html +++ b/allianceauth/corputils/templates/corputils/corpstats.html @@ -9,9 +9,9 @@ + class="ra-avatar" src="{{ corpstats.corp.logo_url_128 }}"> {% if corpstats.corp.alliance %} - {% endif %} @@ -70,6 +70,7 @@ {% for alt in main.alts %} {% if forloop.first %} + @@ -77,10 +78,15 @@ {% endif %} + -
+ src="{{ main.portrait_url_128 }}">
+ {{ char.character_name }} {{ char.corporation_name }}
+
{% trans "Character" %} {% trans "Corporation" %} {% trans "Alliance" %}
+
+ +
+
{{ alt.character_name }} {{ alt.corporation_name }} {{ alt.alliance_name }} + {% trans "Killboard" %} diff --git a/allianceauth/eveonline/models.py b/allianceauth/eveonline/models.py index b7754c52..5e602e94 100644 --- a/allianceauth/eveonline/models.py +++ b/allianceauth/eveonline/models.py @@ -35,6 +35,15 @@ class EveAllianceInfo(models.Model): def __str__(self): return self.alliance_name + def logo_url(self, size=32): + return "https://image.eveonline.com/Alliance/%s_%s.png" % (self.alliance_id, size) + + def __getattr__(self, item): + if item.startswith('logo_url_'): + size = item.strip('logo_url_') + return self.logo_url(size) + return self.__getattribute__(item) + class EveCorporationInfo(models.Model): corporation_id = models.CharField(max_length=254, unique=True) @@ -60,6 +69,15 @@ class EveCorporationInfo(models.Model): def __str__(self): return self.corporation_name + def logo_url(self, size=32): + return "https://image.eveonline.com/Corporation/%s_%s.png" % (self.corporation_id, size) + + def __getattr__(self, item): + if item.startswith('logo_url_'): + size = item.strip('logo_url_') + return self.logo_url(size) + return self.__getattribute__(item) + class EveCharacter(models.Model): character_id = models.CharField(max_length=254, unique=True) @@ -107,3 +125,12 @@ class EveCharacter(models.Model): def __str__(self): return self.character_name + + def portrait_url(self, size=32): + return "https://image.eveonline.com/Character/%s_%s.jpg" % (self.character_id, size) + + def __getattr__(self, item): + if item.startswith('portrait_url_'): + size = item.strip('portrait_url_') + return self.portrait_url(size) + return self.__getattribute__(item)