From 5ae7908036c081c642aafd1c37dfaf9b94bf2445 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 16 Feb 2017 15:42:45 +0100 Subject: [PATCH] fix thumbnail issues + some cleanup --- .../templates/catalogue/book_delete.html | 2 +- .../templates/catalogue/book_list/book.html | 7 +--- .../catalogue/book_list/book_list.html | 14 +++---- .../templates/catalogue/book_owner.html | 2 +- .../templates/catalogue/book_schedule.html | 12 +++--- .../templates/catalogue/book_text.html | 2 +- .../templates/catalogue/finished.html | 2 +- .../templates/catalogue/upcoming.html | 2 +- .../migrations/0010_auto_20170216_1508.py | 31 ++++++++++++++ apps/organizations/models.py | 41 +------------------ .../templates/organizations/main.html | 5 ++- .../organizations/snippets/card.html | 39 ++++++++++++++++++ .../organizations/snippets/organization.html | 38 +---------------- .../organizations/snippets/user.html | 40 +----------------- .../templates/organizations/user_card.html | 3 +- redakcja/templates/main.html | 4 +- 16 files changed, 100 insertions(+), 144 deletions(-) create mode 100644 apps/organizations/migrations/0010_auto_20170216_1508.py create mode 100644 apps/organizations/templates/organizations/snippets/card.html diff --git a/apps/catalogue/templates/catalogue/book_delete.html b/apps/catalogue/templates/catalogue/book_delete.html index a32c3446..23a41a50 100644 --- a/apps/catalogue/templates/catalogue/book_delete.html +++ b/apps/catalogue/templates/catalogue/book_delete.html @@ -6,7 +6,7 @@ {% if doc.owner_organization %} {{ doc.owner_organization }} {% else %} - {{ doc.owner_user.first_name }} {{ doc.owner_user.last_name }} + {{ doc.owner_user.get_full_name }} {% endif %} /

{{ doc.meta.title }}

diff --git a/apps/catalogue/templates/catalogue/book_list/book.html b/apps/catalogue/templates/catalogue/book_list/book.html index fa6a14a0..fd8f785d 100755 --- a/apps/catalogue/templates/catalogue/book_list/book.html +++ b/apps/catalogue/templates/catalogue/book_list/book.html @@ -4,7 +4,7 @@ {{ book.meta.title }} {% if book.owner_user %} - {{ book.owner_user.first_name }} {{ book.owner_user.last_name }} + {{ book.owner_user.get_full_name }} {% else %} {{ book.owner_organization }} {% endif %} @@ -13,7 +13,7 @@ {% endif %} {{ book.stage|default:"–" }} - {% if book.assigned_to %}{{ book.assigned_to.first_name }} {{ book.assigned_to.last_name }}{% endif %} + {% if book.assigned_to %}{{ book.assigned_to.get_full_name }}{% endif %} {{ book.get_plan.deadline|default:"–" }} {% if am_owner %} @@ -25,6 +25,3 @@ {% endif %} - - - diff --git a/apps/catalogue/templates/catalogue/book_list/book_list.html b/apps/catalogue/templates/catalogue/book_list/book_list.html index 97f0a59c..7277f804 100755 --- a/apps/catalogue/templates/catalogue/book_list/book_list.html +++ b/apps/catalogue/templates/catalogue/book_list/book_list.html @@ -5,12 +5,12 @@ {% autopaginate books 100 %} - - - - - - + + + + + + {% for doc in books %} @@ -28,6 +28,6 @@ diff --git a/apps/catalogue/templates/catalogue/book_owner.html b/apps/catalogue/templates/catalogue/book_owner.html index 1ee24337..19a31f96 100644 --- a/apps/catalogue/templates/catalogue/book_owner.html +++ b/apps/catalogue/templates/catalogue/book_owner.html @@ -6,7 +6,7 @@ {% if doc.owner_organization %} {{ doc.owner_organization }} {% else %} - {{ doc.owner_user.first_name }} {{ doc.owner_user.last_name }} + {{ doc.owner_user.get_full_name }} {% endif %} /

{{ doc.meta.title }}

diff --git a/apps/catalogue/templates/catalogue/book_schedule.html b/apps/catalogue/templates/catalogue/book_schedule.html index 79fe1b48..d2c0d52b 100644 --- a/apps/catalogue/templates/catalogue/book_schedule.html +++ b/apps/catalogue/templates/catalogue/book_schedule.html @@ -11,7 +11,7 @@ {% if book.owner_organization %} {{ book.owner_organization }} {% else %} - {{ book.owner_user.first_name }} {{ book.owner_user.last_name }} + {{ book.owner_user.get_full_name }} {% endif %} /

{{ book.meta.title }}

@@ -25,9 +25,9 @@
{% trans "Title" %}{% trans "Owner" %}{% trans "Stage" %}{% trans "Assigned to" %}{% trans "Deadline" %}{% trans "Title" %}{% trans "Owner" %}{% trans "Stage" %}{% trans "Assigned to" %}{% trans "Deadline" %}
- - - + + + {% for i, sch, data in schedule %} @@ -42,11 +42,11 @@ {% if u.pk == data.0 %} selected="selected" {% endif %} - >{{ u.first_name }} {{ u.last_name }} + >{{ u.get_full_name }} {% endfor %} {% else %} - {{ people.0.first_name }} {{ people.0.last_name }} + {{ people.0.get_full_name }} {% endif %} diff --git a/apps/catalogue/templates/catalogue/book_text.html b/apps/catalogue/templates/catalogue/book_text.html index e1e6c415..6cf5f13d 100644 --- a/apps/catalogue/templates/catalogue/book_text.html +++ b/apps/catalogue/templates/catalogue/book_text.html @@ -27,7 +27,7 @@ {% endif %} {% else %} - + {% endif %} diff --git a/apps/catalogue/templates/catalogue/upcoming.html b/apps/catalogue/templates/catalogue/upcoming.html index e7177fcb..a95c9b36 100644 --- a/apps/catalogue/templates/catalogue/upcoming.html +++ b/apps/catalogue/templates/catalogue/upcoming.html @@ -24,7 +24,7 @@ {% trans "Audience" %}: {{ doc.meta.audience }}
{% endif %} {% trans "Owner" %}: {{ doc.owner_organization|default:"" }} - {{ doc.owner_user.first_name }} {{ doc.owner_user.last_name }}
+ {{ doc.owner_user.get_full_name }}
diff --git a/apps/organizations/migrations/0010_auto_20170216_1508.py b/apps/organizations/migrations/0010_auto_20170216_1508.py new file mode 100644 index 00000000..a99c3cfa --- /dev/null +++ b/apps/organizations/migrations/0010_auto_20170216_1508.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.12 on 2017-02-16 15:08 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organizations', '0009_auto_20170119_1321'), + ] + + operations = [ + migrations.RemoveField( + model_name='organization', + name='preview_html', + ), + migrations.RemoveField( + model_name='organization', + name='preview_html_pl', + ), + migrations.RemoveField( + model_name='usercard', + name='preview_html', + ), + migrations.RemoveField( + model_name='usercard', + name='preview_html_pl', + ), + ] diff --git a/apps/organizations/models.py b/apps/organizations/models.py index 8e04ddb7..0919f761 100644 --- a/apps/organizations/models.py +++ b/apps/organizations/models.py @@ -5,8 +5,6 @@ from django.core.urlresolvers import reverse from django.contrib.auth.models import User from django.db import models from django.utils.encoding import python_2_unicode_compatible -from django.template.loader import render_to_string -from django.utils import translation countries = [ @@ -49,26 +47,11 @@ class Card(models.Model): description = models.TextField(blank=True, default="") projects = models.TextField(blank=True, default="") - preview_html = models.TextField(blank=True, default="") - preview_html_pl = models.TextField(blank=True, default="") - created_at = models.DateTimeField(auto_now_add=True) class Meta: abstract = True - def save(self, *args, **kwargs): - translation.activate('en') - self.preview_html = render_to_string(self.preview_html_template, { - 'org': self - }) - translation.activate('pl') - self.preview_html_pl = render_to_string(self.preview_html_template, { - 'org': self - }) - ret = super(Card, self).save(*args, **kwargs) - return ret - def get_projects(self): for project_line in self.projects.strip().split('\n'): parts = project_line.strip().split(None, 2) @@ -77,23 +60,13 @@ class Card(models.Model): url, lang, desc = (parts + [''] * 2)[:3] yield url, lang, desc - def get_preview_html(self): - lang = translation.get_language() - try: - p = getattr(self, "preview_html_%s" % lang) - assert p - return p - except (AssertionError, AttributeError): - return self.preview_html - @python_2_unicode_compatible class UserCard(Card): - preview_html_template = 'organizations/snippets/user.html' user = models.OneToOneField(User, primary_key=True) def __str__(self): - return str(self.user) + return self.user.get_full_name() def get_absolute_url(self): return reverse('organizations_user', args=[self.user.pk]) @@ -101,20 +74,8 @@ class UserCard(Card): @python_2_unicode_compatible class Organization(Card): - preview_html_template = 'organizations/snippets/organization.html' - name = models.CharField(max_length=1024) tags = models.ManyToManyField('catalogue.Tag', blank=True) - # logo = models.ImageField(upload_to='people/logo', blank=True) - # country = models.CharField(max_length=64, blank=True, choices=countries) - # www = models.URLField(blank=True) - # description = models.TextField(blank=True, default="") - # #projects = JSONField(default=[]) - # projects = models.TextField(blank=True, default="") - - # preview_html = models.TextField(blank=True, default="") - - # created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name diff --git a/apps/organizations/templates/organizations/main.html b/apps/organizations/templates/organizations/main.html index 2334be0b..3fcf5593 100644 --- a/apps/organizations/templates/organizations/main.html +++ b/apps/organizations/templates/organizations/main.html @@ -1,6 +1,7 @@ {% extends "catalogue/base.html" %} {% load i18n %} {% load document_list from document_list %} +{% load thumbnail %} {% block inner_content %} @@ -13,7 +14,7 @@ {% trans "New resource +" %} {% endif %} - {{ org.get_preview_html|safe }} + {% include "organizations/snippets/organization.html" %} {% if tab == 'members' %} @@ -36,7 +37,7 @@ {% for m in org.membership_set.all %} {% if am_owner or m.status != 'pending' or m.user == request.user %} - + {% if am_owner %}{% endif %}
{% trans "Stage" %}{% trans "Person" %}{% trans "Deadline" %}{% trans "Stage" %}{% trans "Person" %}{% trans "Deadline" %}
{{ m.user.first_name }} {{ m.user.last_name }}{{ m.user.get_full_name }}{{ m.user.email }} {% if m.status == 'owner' %} diff --git a/apps/organizations/templates/organizations/snippets/card.html b/apps/organizations/templates/organizations/snippets/card.html new file mode 100644 index 00000000..0332565f --- /dev/null +++ b/apps/organizations/templates/organizations/snippets/card.html @@ -0,0 +1,39 @@ +{% load thumbnail %} +{% load i18n %} +{% load urlinfo %} + + +{% if org.logo %} + +{% endif %} + +

{{ org }}

+ + {% if org.country %}{% endif %} + {% if org.www %}{% endif %} + + {% if org.description %} + + {% endif %} + + {% for url, lang, desc in org.get_projects %} + {% if forloop.first %} + + {% endif %} + {% urlinfo url as ui %} + + + + + {% endfor %} +
{% trans "Country" %}:{{ org.get_country_display }}
{% trans "WWW" %}:{{ org.www }}
{% trans "Description" %}:{{ org.description }}
{% trans "Main projects and publications" %}:
+ {% if ui.picture_url %} + + {% thumbnail ui.picture_url '120x40' format="PNG" as th %} + + {% endthumbnail %} + + {% endif %} + {{ desc }}
+ {{ url }} {% if lang %}({{ lang }}){% endif %} +
diff --git a/apps/organizations/templates/organizations/snippets/organization.html b/apps/organizations/templates/organizations/snippets/organization.html index 0e60edca..1fe58df0 100644 --- a/apps/organizations/templates/organizations/snippets/organization.html +++ b/apps/organizations/templates/organizations/snippets/organization.html @@ -1,37 +1 @@ -{% load thumbnail %} -{% load i18n %} -{% load urlinfo %} - - -{% if org.logo %} - -{% endif %} - -

{{ org }}

- - - - - {% if org.description %} - - {% endif %} - - - {% for url, lang, desc in org.get_projects %} - {% urlinfo url as ui %} - - - - - {% endfor %} -
{% trans "Country" %}:{{ org.get_country_display }}
{% trans "WWW" %}:{{ org.www }}
{% trans "Description" %}:{{ org.description }}
{% trans "Main projects and publications" %}:
- {% if ui.picture_url %} - - {% thumbnail ui.picture_url '120x40' format="PNG" as th %} - - {% endthumbnail %} - - {% endif %} - {{ desc }}
- {{ url }} {% if lang %}({{ lang }}){% endif %} -
+{% extends "organizations/snippets/card.html" %} \ No newline at end of file diff --git a/apps/organizations/templates/organizations/snippets/user.html b/apps/organizations/templates/organizations/snippets/user.html index b8aeb47b..1fe58df0 100644 --- a/apps/organizations/templates/organizations/snippets/user.html +++ b/apps/organizations/templates/organizations/snippets/user.html @@ -1,39 +1 @@ -{% load thumbnail %} -{% load i18n %} -{% load urlinfo %} - - -{% if org.logo %} - -{% endif %} - -

{{ org.user.first_name }} {{ org.user.last_name }}

- - {% if org.country %}{% endif %} - {% if org.www %}{% endif %} - - {% if org.description %} - - {% endif %} - - {% for url, lang, desc in org.get_projects %} - {% if forloop.first %} - - {% endif %} - {% urlinfo url as ui %} - - - - - {% endfor %} -
{% trans "Country" %}:{{ org.get_country_display }}
{% trans "WWW" %}:{{ org.www }}
{% trans "Description" %}:{{ org.description }}
{% trans "Main projects and publications" %}:
- {% if ui.picture_url %} - - {% thumbnail ui.picture_url '120x40' format="PNG" as th %} - - {% endthumbnail %} - - {% endif %} - {{ desc }}
- {{ url }} {% if lang %}({{ lang }}){% endif %} -
+{% extends "organizations/snippets/card.html" %} \ No newline at end of file diff --git a/apps/organizations/templates/organizations/user_card.html b/apps/organizations/templates/organizations/user_card.html index 513944b4..421243f5 100644 --- a/apps/organizations/templates/organizations/user_card.html +++ b/apps/organizations/templates/organizations/user_card.html @@ -1,6 +1,7 @@ {% extends "catalogue/base.html" %} {% load i18n %} {% load document_list from document_list %} +{% load thumbnail %} {% block inner_content %} @@ -8,7 +9,7 @@ {% trans "Edit" %} {% endif %} - {{ card.get_preview_html|safe }} + {% include "organizations/snippets/user.html" with org=card %}

{% trans "Resources" %}

{% document_list user=card.user.pk %} diff --git a/redakcja/templates/main.html b/redakcja/templates/main.html index a6a9f415..64421c38 100644 --- a/redakcja/templates/main.html +++ b/redakcja/templates/main.html @@ -85,7 +85,7 @@ {% trans "Audience" %}: {{ doc.meta.audience }}
{% endif %} {% trans "Owner" %}: {{ doc.owner_organization|default:"" }} - {{ doc.owner_user.first_name }} {{ doc.owner_user.last_name }}
+ {{ doc.owner_user.get_full_name }}
@@ -115,7 +115,7 @@ {% trans "Audience" %}: {{ doc.meta.audience }}
{% endif %} {% trans "Owner" %}: {{ doc.owner_organization|default:"" }} - {{ doc.owner_user.first_name }} {{ doc.owner_user.last_name }}
+ {{ doc.owner_user.get_full_name }}
-- 2.20.1