Merge lp:~mboehn/lancms/lc2-organization-logo into lp:lancms

Proposed by Mathias Bøhn Grytemark
Status: Merged
Merged at revision: 107
Proposed branch: lp:~mboehn/lancms/lc2-organization-logo
Merge into: lp:lancms
Diff against target: 197 lines (+70/-4)
9 files modified
.bzrignore (+2/-0)
core/migrations/0002_organization_logo.py (+20/-0)
core/migrations/0003_auto_20150104_0007.py (+21/-0)
core/models.py (+8/-0)
lancms2/settings.py (+2/-1)
lancms2/urls.py (+3/-1)
requirements.txt (+2/-0)
templates/event/front.html (+7/-1)
templates/organization/admin.html (+5/-1)
To merge this branch: bzr merge lp:~mboehn/lancms/lc2-organization-logo
Reviewer Review Type Date Requested Status
Mathias Bøhn Grytemark self-review Approve
Review via email: mp+246071@code.launchpad.net

Commit message

Merging basic organization logo support.

Description of the change

Support for organization logo in model, admin and some templates.

To post a comment you must log in.
Revision history for this message
Mathias Bøhn Grytemark (mboehn) wrote :

Works for me.

review: Approve (self-review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-01-11 22:24:01 +0000
3+++ .bzrignore 2015-01-11 18:42:44 +0000
4@@ -2,3 +2,5 @@
5 *.py[co]
6 lancms2/local_settings.py
7 .bzr_rev
8+media/uploads/*
9+static/
10
11=== added file 'core/migrations/0002_organization_logo.py'
12--- core/migrations/0002_organization_logo.py 1970-01-01 00:00:00 +0000
13+++ core/migrations/0002_organization_logo.py 2015-01-11 18:42:44 +0000
14@@ -0,0 +1,20 @@
15+# -*- coding: utf-8 -*-
16+from __future__ import unicode_literals
17+
18+from django.db import models, migrations
19+
20+
21+class Migration(migrations.Migration):
22+
23+ dependencies = [
24+ ('core', '0001_initial'),
25+ ]
26+
27+ operations = [
28+ migrations.AddField(
29+ model_name='organization',
30+ name='logo',
31+ field=models.ImageField(upload_to='', null=True),
32+ preserve_default=True,
33+ ),
34+ ]
35
36=== added file 'core/migrations/0003_auto_20150104_0007.py'
37--- core/migrations/0003_auto_20150104_0007.py 1970-01-01 00:00:00 +0000
38+++ core/migrations/0003_auto_20150104_0007.py 2015-01-11 18:42:44 +0000
39@@ -0,0 +1,21 @@
40+# -*- coding: utf-8 -*-
41+from __future__ import unicode_literals
42+
43+from django.db import models, migrations
44+import core.models
45+
46+
47+class Migration(migrations.Migration):
48+
49+ dependencies = [
50+ ('core', '0002_organization_logo'),
51+ ]
52+
53+ operations = [
54+ migrations.AlterField(
55+ model_name='organization',
56+ name='logo',
57+ field=models.ImageField(null=True, upload_to=core.models.logo_rename),
58+ preserve_default=True,
59+ ),
60+ ]
61
62=== modified file 'core/models.py'
63--- core/models.py 2014-12-29 22:09:09 +0000
64+++ core/models.py 2015-01-11 18:42:44 +0000
65@@ -8,6 +8,8 @@
66 from django.contrib.auth.models import User, Group
67 from django_countries.fields import CountryField
68
69+from uuid import uuid4
70+import os
71
72 CHOICES_GENDER = (
73 ('female', _('Female')),
74@@ -44,6 +46,11 @@
75 pass
76
77
78+def logo_rename (instance, filename):
79+ path = 'uploads/logo/'
80+ filename = uuid4().hex
81+ return os.path.join(path, filename)
82+
83 class Organization (models.Model):
84 name = models.CharField (max_length=64, verbose_name=_('Name'))
85 about = models.TextField (null=True, verbose_name=_('About'))
86@@ -51,6 +58,7 @@
87 is_active = models.BooleanField (default=False, verbose_name=_('Activated'))
88 urlslug = models.SlugField (unique=True, verbose_name=_('URL-slug'))
89 externalurl = models.URLField (null=True, verbose_name=_('External website'))
90+ logo = models.ImageField (null=True, upload_to=logo_rename)
91
92
93 def __unicode__ (self):
94
95=== modified file 'lancms2/settings.py'
96--- lancms2/settings.py 2015-01-03 16:03:29 +0000
97+++ lancms2/settings.py 2015-01-11 18:42:44 +0000
98@@ -47,6 +47,7 @@
99 'bootstrapform',
100 'ticket',
101 'crew',
102+ 'easy_thumbnails',
103 )
104
105 MIDDLEWARE_CLASSES = (
106@@ -96,7 +97,7 @@
107 # https://docs.djangoproject.com/en/1.6/howto/static-files/
108
109 STATIC_URL = '/static/'
110-
111+MEDIA_URL = '/media/'
112
113 #####
114 MEDIA_ROOT = os.path.join (BASE_DIR, 'media/')
115
116=== modified file 'lancms2/urls.py'
117--- lancms2/urls.py 2014-10-11 15:47:37 +0000
118+++ lancms2/urls.py 2015-01-11 18:42:44 +0000
119@@ -1,4 +1,6 @@
120 from django.conf.urls import patterns, include, url
121+from django.conf import settings
122+from django.conf.urls.static import static
123
124 # Uncomment the next two lines to enable the admin:
125 from django.contrib import admin
126@@ -32,4 +34,4 @@
127 url(r'^\+admin/doc/', include('django.contrib.admindocs.urls')),
128 # Uncomment the next line to enable the admin:
129 url(r'^\+admin/', include(admin.site.urls)),
130-)
131+) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
132
133=== added directory 'media/uploads'
134=== modified file 'requirements.txt'
135--- requirements.txt 2015-01-03 16:53:49 +0000
136+++ requirements.txt 2015-01-11 18:42:44 +0000
137@@ -1,9 +1,11 @@
138 Django==1.7.2
139+Pillow==2.7.0
140 defusedxml==0.4.1
141 django-allauth==0.18.0
142 django-bootstrap-form==3.1
143 django-countries==3.0.2
144 django-debug-toolbar==1.2.2
145+easy-thumbnails==2.2
146 oauthlib==0.7.2
147 python3-openid==3.0.5
148 requests==2.5.1
149
150=== modified file 'templates/event/front.html'
151--- templates/event/front.html 2014-01-18 20:06:43 +0000
152+++ templates/event/front.html 2015-01-11 18:42:44 +0000
153@@ -1,5 +1,6 @@
154 {% extends "base.html" %}
155 {% load i18n %}
156+{% load thumbnail %}
157
158 {% block content %}
159 <div class="jumbotron">
160@@ -46,7 +47,12 @@
161 <div class="panel panel-default">
162 <div class="panel-heading">{% trans "Organized by" %}</div>
163 <div class="panel-body">
164- {{event.organization.name}}
165+ {% if organization.logo %}
166+ {% thumbnail organization.logo 100x100 upscale as thumb %}
167+ <a href="{% url 'organization_front' slug=organization.urlslug %}"><img src="{{thumb.url}}" height="{{thumb.height}}" width="{{thumb.width}}" alt="Organization logo" class="img-responsive center-block"></a>
168+ {% else %}
169+ {{event.organization.name}}
170+ {% endif %}
171 </div>
172 </div>
173 </div>
174
175=== modified file 'templates/organization/admin.html'
176--- templates/organization/admin.html 2014-07-22 15:47:58 +0000
177+++ templates/organization/admin.html 2015-01-11 18:42:44 +0000
178@@ -1,6 +1,7 @@
179 {% extends "base.html" %}
180 {% load i18n %}
181 {% load owns_org %}
182+{% load thumbnail %}
183
184 {% block content %}
185
186@@ -26,7 +27,10 @@
187 {% trans "Logo/Image" %}<a class="fa fa-edit pull-right" href="#FIXME"></a>
188 </div>
189 <div class="panel-body">
190- {{organization.image}}
191+ {% if organization.logo %}
192+ {% thumbnail organization.logo 100x100 upscale as thumb %}
193+ <img src="{{thumb.url}}" height="{{thumb.height}}" width="{{thumb.width}}" alt="Organization logo" class="img-responsive center-block">
194+ {% endif %}
195 </div>
196 </div>
197 </div>

Subscribers

People subscribed via source and target branches