def view(request, id): community = get_object_or_404(Community, pk=id) geojson = create_geojson([community]) photos = paginated_query(UploadedFile.get_files_for(community), request, size=3) return dict(community=community, geojson=geojson, photos=photos)
def show(request, id=''): organization = get_object_or_404(Organization, pk=id) geojson = create_geojson([organization]) files = UploadedFile.get_files_for(organization) if organization.logo_id: files = files.exclude(pk=organization.logo_id) return dict(organization=organization, geojson=geojson)
def show(request, id=""): organization = get_object_or_None(Organization, pk=id) or Organization() geojson = create_geojson([organization]) files = UploadedFile.get_files_for(organization) if organization.logo_id: files = files.exclude(pk=organization.logo_id) return dict(organization=organization, geojson=geojson)
def show(request, id=''): organization = get_object_or_None(Organization, pk=id) or Organization() branches = organization.organizationbranch_set.all().order_by('name') geojson = create_geojson(branches) files = UploadedFile.get_files_for(organization) if organization.logo_id: files = files.exclude(pk=organization.logo_id) return dict(organization=organization, geojson=geojson)
def load_files(context, obj=None): if obj: files = UploadedFile.get_files_for(obj) object_id = obj.id content_type = ContentType.objects.get_for_model(obj).id else: files = [] object_id = '' content_type = '' return dict(files=files, object_id=object_id, content_type=content_type)
def info_window(request, zoom, app_label, model_name, obj_id): model = get_model(app_label, model_name) obj = get_object_or_404(model, id=obj_id) if model else None images = UploadedFile.get_files_for(obj) try: image = images.get(cover=True) except UploadedFile.DoesNotExist: image = None if not image: # Have no selected image. Get the first one. try: image = images.all()[:1].get() except UploadedFile.DoesNotExist: image = None template = getattr(obj, 'info_window_template', 'komoo_map/info_window.html') return render_to_response(template, {'object': obj, 'zoom': zoom, 'image': image}, context_instance=RequestContext(request))
def files_set(self): """ pseudo-reverse query for retrieving Resource Files""" return UploadedFile.get_files_for(self)
def files_set(self): """ pseudo-reverse query for retrieving Organization Files""" return UploadedFile.get_files_for(self)
def partners_logo(self): """ pseudo-reverse query for retrieving the partners logo""" return UploadedFile.get_files_for(self)
def image_gallery(context, obj=None): images = UploadedFile.get_files_for(obj) if obj else [] return dict(images=images)