#1532 Don't show project icon placeholder

v1.0.0
closed
nobody
General
nobody
2015-08-20
2011-02-18
No

The gray project icon placeholder doesn't look very good. So if there is no project icon, don't show the placeholder in the project header. Just the project name.

Discussion

  • Mark Ramm - 2011-02-23
    • milestone: mar-03 --> backlog
     
  • Dave Brondsema

    Dave Brondsema - 2011-08-11
    • Description has changed:

    Diff:

    --- old 
    +++ new 
    @@ -1,3 +1,3 @@
     The gray project icon placeholder doesn't look awesome when used everywhere, so only show it to project admins (to encourage them to upload an icon).  This will be consistent with sfpy also.
    
    -Make sure this affects neighborhoods too, so there is no placeholder at https://sourceforge.net/p/
    +Make sure this affects neighborhoods too, so there is no placeholder at https://sourceforge.net/p/  And the project-card display on pages using the `[[projects ...]]` macro.
    
     
  • Dave Brondsema

    Dave Brondsema - 2012-05-09
    • Description has changed:

    Diff:

    --- old 
    +++ new 
    @@ -1,3 +1,1 @@
     The gray project icon placeholder doesn't look awesome when used everywhere, so only show it to project admins (to encourage them to upload an icon).  This will be consistent with sfpy also.
    -
    -Make sure this affects neighborhoods too, so there is no placeholder at https://sourceforge.net/p/  And the project-card display on pages using the `[[projects ...]]` macro.
    
     
  • Dave Brondsema

    Dave Brondsema - 2012-05-10
    • labels: --> adobe, 42cc
    • summary: Only show project icon placeholder to admins --> Don't show project icon placeholder
    • Description has changed:

    Diff:

    --- old 
    +++ new 
    @@ -1,1 +1,1 @@
    -The gray project icon placeholder doesn't look awesome when used everywhere, so only show it to project admins (to encourage them to upload an icon).  This will be consistent with sfpy also.
    +The gray project icon placeholder doesn't look very good.  So if there is no project icon, don't show the placeholder in the project header.  Just the project name.
    
     
  • Yaroslav Luzin - 2012-05-14

    Created ticket #50: [1532] Don't show project icon placeholder (1cp)

     
  • Anonymous - 2012-05-17

    Originally by: stilgar-dev

    Hi!

    I've made necessary changes to all the places where this image have been used as project icon placeholder (but not where it's used as temporary non-configurable label for another purposes).

    That changes broke 7 tests, that expecting each project to have an icon. I'm trying to set icon where it's required, but having problem with that.

    Essential: Allura/allura/tests/functional/test_root:TestRootController.test_index fails, as there is no tag outputted in template Allura/allura/templates/widgets/project_summary.html, that is used by widget Allura/allura/lib/widgets/project_list.py:ProjectSummary, because there is no icon of the project.

    Excuse me, there will be a large amount of text to give all necessary information.

    Error message of the first failing test:

    ERROR: allura.tests.functional.test_root.TestRootController.test_index
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/www/allura/env/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
        self.test(*self.arg)
      File "/home/www/allura/Allura/allura/tests/functional/test_root.py", line 46, in test_index
        assert projects[0].find('img').get('alt') == 'adobe-1 Logo'
    AttributeError: 'NoneType' object has no attribute 'get'
    -------------------- >> begin captured stdout << ---------------------
    Running setup_app() from allura.websetup
    
    --------------------- >> end captured stdout << ----------------------
    -------------------- >> begin captured logging << --------------------
    pylons.configuration: DEBUG: Initializing configuration, package: 'allura'
    routes.middleware: DEBUG: Initialized with method overriding = True, and path info altering = True
    ew.resource: INFO: Loading ep ew_resources = allura.config.resources:register_ew_resources
    ew.resource: INFO: Loading ep ew_resources = forgetracker.config.resources:register_ew_resources
    ew.render: DEBUG: Loading template engine jinja
    ew.render: DEBUG: Loading template engine kajiki-text
    ew.render: DEBUG: Error loading engine kajiki-text
    ew.render: DEBUG: Loading template engine kajiki
    ew.render: DEBUG: Error loading engine kajiki
    ew.render: DEBUG: Loading template engine kajiki-html5
    ew.render: DEBUG: Error loading engine kajiki-html5
    ew.render: DEBUG: Loading template engine kajiki-html4
    ew.render: DEBUG: Error loading engine kajiki-html4
    ew.render: DEBUG: Loading template engine json
    ew.render: DEBUG: Loading template engine jinja2
    ew.render: DEBUG: Loading template engine kajiki-xml
    ew.render: DEBUG: Error loading engine kajiki-xml
    ew.render: DEBUG: Loading template engine genshi
    ew.render: DEBUG: Loading template engine core-ew
    ew.render: DEBUG: Loading template engine jinja
    ew.render: DEBUG: Loading template engine kajiki-text
    ew.render: DEBUG: Error loading engine kajiki-text
    ew.render: DEBUG: Loading template engine kajiki
    ew.render: DEBUG: Error loading engine kajiki
    ew.render: DEBUG: Loading template engine kajiki-html5
    ew.render: DEBUG: Error loading engine kajiki-html5
    ew.render: DEBUG: Loading template engine kajiki-html4
    ew.render: DEBUG: Error loading engine kajiki-html4
    ew.render: DEBUG: Loading template engine json
    ew.render: DEBUG: Loading template engine jinja2
    ew.render: DEBUG: Loading template engine kajiki-xml
    ew.render: DEBUG: Error loading engine kajiki-xml
    ew.render: DEBUG: Loading template engine genshi
    ew.render: DEBUG: Loading template engine core-ew
    --------------------- >> end captured logging << ---------------------
    

    That is expected to happen, as in appropriate template I've made tag to not be outputted when there is no icon.

    I'm trying to fix those tests by setting project icons where necessary, but having problem setting icon. To achieve that, at the end of TestRootController.setUp() in Allura/allura/tests/functional/test_root.py I've added

    p_adobe1 = M.Project.query.get(name='adobe-1')
    M.ProjectFile.save_image(
            'project_default.png',
            'allura/public/nf/images/project_default.png',
            thumbnail_size=(48,48),
            thumbnail_meta=dict(
                project_id=p_adobe1._id,
                category='icon'))
    

    I've used code in ProjectAdminController.update() in Allura/allura/ext/admin/admin_main.py as reference.

    But test Allura/allura/tests/functional/test_root.py:TestRootController.test_index is still failing in the same way.

    Here's some information from pdb session started in test method (after I've added code to setUp()):

    (Pdb) p_adobe1 = M.Project.query.get(name='adobe-1')
    (Pdb) p_adobe1.icon
    <ProjectFile category=u'icon'
      _id=ObjectId('4fb4d346abd8d0551c00031e')
      filename=u'project_default.png' caption=None
      file_id=ObjectId('4fb4d346abd8d0551c000320')
      content_type=u'image/png'
      project_id=ObjectId('4fb4d345abd8d0551c0002e7')>
    (Pdb) M.ProjectFile.remove(dict(project_id=p_adobe1._id, category='icon'))
    (Pdb) p_adobe1.icon
    <ProjectFile category=u'icon'
      _id=ObjectId('4fb4d346abd8d0551c00031e')
      filename=u'project_default.png' caption=None
      file_id=ObjectId('4fb4d346abd8d0551c000320')
      content_type=u'image/png'
      project_id=ObjectId('4fb4d345abd8d0551c0002e7')>
    (Pdb) M.ProjectFile.save_image('project_default.png', open('allura/public/nf/images/project_default.png'), thumbnail_size=(48,48), thumbnail_meta=dict(project_id=p_adobe1._id, category='icon'))
    (None, <ProjectFile category='icon'
      _id=ObjectId('4fb4d515abd8d0551c00032a')
      filename='project_default.png' caption=None
      file_id=ObjectId('4fb4d515abd8d0551c00032c')
      content_type='image/png'
      project_id=ObjectId('4fb4d345abd8d0551c0002e7')>)
    (Pdb) p_adobe1.icon
    <ProjectFile category=u'icon'
      _id=ObjectId('4fb4d346abd8d0551c00031e')
      filename=u'project_default.png' caption=None
      file_id=ObjectId('4fb4d346abd8d0551c000320')
      content_type=u'image/png'
      project_id=ObjectId('4fb4d345abd8d0551c0002e7')>
    (Pdb) p_adobe1 = M.Project.query.get(name='adobe-1')
    (Pdb) p_adobe1.icon
    <ProjectFile category=u'icon'
      _id=ObjectId('4fb4d346abd8d0551c00031e')
      filename=u'project_default.png' caption=None
      file_id=ObjectId('4fb4d346abd8d0551c000320')
      content_type=u'image/png'
      project_id=ObjectId('4fb4d345abd8d0551c0002e7')>
    

    Take a notice that _id of created ProjectFile doesn't match _id of icon. That looks like icon is being set in setUp() and can't be changed. Problem is that ProjectSummary widget, that generates page requested in test doesn't see an icon in that project.

    Pdb session started in setUp() after assigning icon:

    (Pdb) p_adobe1.icon
    (Pdb) p_adobe1 = M.Project.query.get(name='adobe-1')
    (Pdb) p_adobe1.icon
    (Pdb) M.ProjectFile.save_image('project_default.png', open('allura/public/nf/images/project_default.png'), thumbnail_size=(48,48), thumbnail_meta=dict(project_id=p_adobe1._id, category='icon'))
    (None, <ProjectFile category='icon'
      _id=ObjectId('4fb4d8e5abd8d05684000322')
      filename='project_default.png' caption=None
      file_id=ObjectId('4fb4d8e5abd8d05684000324')
      content_type='image/png'
      project_id=ObjectId('4fb4d8bcabd8d056840002e7')>)
    (Pdb) p_adobe1.icon
    (Pdb) p_adobe1 = M.Project.query.get(name='adobe-1')
    (Pdb) p_adobe1.icon
    (Pdb)
    

    So I don't understand how setting project icon works and, maybe, why widget ProjectFile doesn't see an icon in project. Can you please give me a hint on what I'm doing wrong or point me to some documentation?

    Thank you those who at least achieved reading to this point. :-)

     
  • Dave Brondsema

    Dave Brondsema - 2012-05-21

    It also seems strange that after calling M.ProjectFile.remove there still was a value for p_adobe1.icon. Perhaps what is needed is to flush the ming ORM session after saving and deleting. ThreadLocalORMSession.flush_all() is a common way to do it, but if you grep for flush you can see other examples (e.g. if you already have a session reference).

    It's not really necessary for test_index to assert that an icon is there, so if this continues to be difficult to change, you could just remove that assertion. But I do think it would be valuable to have an icon set up for the test, so hopefully that will work.

     
  • Yaroslav Luzin - 2012-05-21

    We've finished with the ticket, all changes are in 42cc_1532

    • status: open --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2012-05-29
    • status: code-review --> closed
    • milestone: forge-backlog --> forge-jun-01
     
  • Dave Brondsema

    Dave Brondsema - 2012-05-29

    Nice work. It'd be slightly better to use context managers (with statement) for opening files and for saving & restoring the Allura context (e.g. with h.push_context(...):), but its not necessary to change that for this code since it's already done and working.

     

Log in to post a comment.