Fix a bug where a template "endif" was removed

There is still a regression where a session with no views always shows
"0 Images", even if the user has only view permissions.
Merge branch 'fix-session'

* fix-session:
  Fix a bug where a template "endif" was removed