fixes to handle oprhan templates and templates assigned to shared sites(PBS)

linked with LUN-368 on lunchbox and LUN-368 on django-cms-dbtemplates