You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2017/01/31 20:27:09 UTC
[7/7] allura git commit: [#8143] hi-res neighborhood icons;
adjust to share Project logic
[#8143] hi-res neighborhood icons; adjust to share Project logic
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e3a19fb0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e3a19fb0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e3a19fb0
Branch: refs/heads/db/8143
Commit: e3a19fb06df304c0575918da9217a73af9c73750
Parents: 2b894fc
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Jan 31 14:47:43 2017 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Jan 31 15:21:53 2017 -0500
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 17 +++++++++++------
Allura/allura/lib/widgets/forms.py | 2 +-
Allura/allura/model/neighborhood.py | 8 +++++++-
.../templates/jinja_master/neigh_nav_menu.html | 3 ++-
.../widgets/neighborhood_overview_form.html | 2 +-
5 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/e3a19fb0/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 32167dc..6854c00 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -246,8 +246,15 @@ class NeighborhoodController(object):
redirect(c.project.script_name + 'admin/?first-visit')
@expose()
- def icon(self, **kw):
- icon = self.neighborhood.icon
+ def icon(self, w=None, **kw):
+ try:
+ icon = c.project.icon_sized(w=int(w or 48))
+ except ValueError as e:
+ log.info('Invalid project icon size: %s on %s', e, request.url)
+ icon = None
+ if icon is None and w is None:
+ # fallback to older icons stored with neighborhood_id rather than using the nbhd project_id
+ icon = self.neighborhood.icon
if not icon:
raise exc.HTTPNotFound
return icon.serve()
@@ -674,11 +681,9 @@ class NeighborhoodAdminController(object):
if icon is not None and icon != '':
if self.neighborhood.icon:
self.neighborhood.icon.delete()
+ M.ProjectFile.query.remove(dict(project_id=c.project._id, category=re.compile(r'^icon')))
M.AuditLog.log('update neighborhood icon')
- M.NeighborhoodFile.save_image(
- icon.filename, icon.file, content_type=icon.type,
- square=True, thumbnail_size=(48, 48),
- thumbnail_meta=dict(neighborhood_id=self.neighborhood._id))
+ c.project.save_icon(icon.filename, icon.file, content_type=icon.type)
redirect('overview')
@expose('jinja:allura:templates/neighborhood_help.html')
http://git-wip-us.apache.org/repos/asf/allura/blob/e3a19fb0/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 91e7dee..98d7efe 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -805,7 +805,7 @@ class NeighborhoodOverviewForm(ForgeForm):
css = ffw.AutoResizeTextarea()
project_template = ffw.AutoResizeTextarea(
validator=V.JsonValidator(if_empty=''))
- icon = ew.FileField()
+ icon = ew.FileField(attrs={'accept': 'image/*'})
tracking_id = ew.TextField()
project_list_url = ew.TextField()
anchored_tools = ffw.AutoResizeTextarea()
http://git-wip-us.apache.org/repos/asf/allura/blob/e3a19fb0/Allura/allura/model/neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/neighborhood.py b/Allura/allura/model/neighborhood.py
index b27be4d..1c7ff9e 100644
--- a/Allura/allura/model/neighborhood.py
+++ b/Allura/allura/model/neighborhood.py
@@ -165,7 +165,13 @@ class Neighborhood(MappedClass):
@property
def icon(self):
- return NeighborhoodFile.query.get(neighborhood_id=self._id)
+ # New icon storage uses the neighborhood_project object, so Project.icon* methods can be shared
+ if self.neighborhood_project.get_tool_data('allura', 'icon_original_size'):
+ icon = self.neighborhood_project.icon
+ else:
+ # fallback to older storage location
+ icon = NeighborhoodFile.query.get(neighborhood_id=self._id)
+ return icon
@property
def allow_custom_css(self):
http://git-wip-us.apache.org/repos/asf/allura/blob/e3a19fb0/Allura/allura/templates/jinja_master/neigh_nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/neigh_nav_menu.html b/Allura/allura/templates/jinja_master/neigh_nav_menu.html
index 907ad5f..d9abc13 100644
--- a/Allura/allura/templates/jinja_master/neigh_nav_menu.html
+++ b/Allura/allura/templates/jinja_master/neigh_nav_menu.html
@@ -16,11 +16,12 @@
specific language governing permissions and limitations
under the License.
-#}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% if not neighborhood or not neighborhood.show_title %}
<div id="nav_menu_missing"></div>
{% else %}
{% if neighborhood.icon %}
- <a href="{{neighborhood.url()}}"><img src="{{neighborhood.url()}}icon" class="project_icon" alt="{{neighborhood.name}} Logo"/></a>
+ <a href="{{neighborhood.url()}}"><img {{ lib.project_icon_srcs(neighborhood.neighborhood_project) }} class="project_icon" alt="{{neighborhood.name}} Logo"/></a>
{% endif %}
<h1 class="project_title"><a href="{{neighborhood.url()}}">{{neighborhood.name}}</a></h1>
{% if neighborhood.project_list_url %}
http://git-wip-us.apache.org/repos/asf/allura/blob/e3a19fb0/Allura/allura/templates/widgets/neighborhood_overview_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_overview_form.html b/Allura/allura/templates/widgets/neighborhood_overview_form.html
index 7ba2a88..936b5ab 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -50,7 +50,7 @@
<label class="grid-4">Icon</label>
<div class="grid-14">
{% if neighborhood.icon %}
- <img src="{{neighborhood.url()}}icon" style="vertical-align: middle" alt=""/>
+ <img {{ lib.project_icon_srcs(neighborhood.neighborhood_project) }} style="vertical-align: middle" alt=""/>
{% endif %}
{{widget.display_field(widget.fields.icon)}}
</div>