# Path: flickr_ckeditor/views.py
# class CkeditorFlickrView(View):
#     """
#     A simple view to get flickr photos to customer.
#     """
#     def get(self, request, *args, **kwargs):
#         num_page = request.GET.get('page')
#         per_page = request.GET.get('per-page')
# 
#         photosets, paginator, page = Photoset.getList()
# 
#         photoset_id = request.GET.get('photoset')
#         photoset_list = [(photoset.id, photoset.title) for photoset in photosets]
# 
#         response_data = {"photosets": photoset_list, 'numOfPages': 1, 'photos': []}
# 
#         if photoset_id:
#             photoset = list(filter(lambda x: x.id == photoset_id, photosets))
# 
#             if len(photoset):
#                 photoset = photoset.pop()
#                 photos, paginator, page = photoset.getPhotos(page=num_page, per_page=per_page)
# 
#                 response_data['photos'] = [{
#                     "id": photo.id,
#                     "title": photo.title,
#                     "large_square_url": photo.large_square_url,
#                     "medium_url": photo.medium_url,
#                     "url": photo.url
#                 } for photo in page]
# 
#                 response_data['numOfPages'] = paginator.num_pages
#                 response_data['totalOfPhotos'] = paginator.total
# 
#         return JsonResponse(response_data)


from django.conf.urls import patterns, url
from flickr_ckeditor.views import CkeditorFlickrView
"""
Example URLConf for a flickr ckeditor.

Needs set url ``/ckeditor/flickr/`` url to works this app.

    >>> urlpatterns = patterns(''
    >>>     ...
    >>>     url(r'^ckeditor/flickr/', include('flickr_ckeditor.urls')),
    >>>     ...
    >>> )
"""



urlpatterns = [
    # ckeditor - need be first - don't erase

# Path: flickr_ckeditor/views.py
# class CkeditorFlickrView(View):
#     """
#     A simple view to get flickr photos to customer.
#     """
#     def get(self, request, *args, **kwargs):
#         num_page = request.GET.get('page')
#         per_page = request.GET.get('per-page')
# 
#         photosets, paginator, page = Photoset.getList()
# 
#         photoset_id = request.GET.get('photoset')
#         photoset_list = [(photoset.id, photoset.title) for photoset in photosets]
# 
#         response_data = {"photosets": photoset_list, 'numOfPages': 1, 'photos': []}
# 
#         if photoset_id:
#             photoset = list(filter(lambda x: x.id == photoset_id, photosets))
# 
#             if len(photoset):
#                 photoset = photoset.pop()
#                 photos, paginator, page = photoset.getPhotos(page=num_page, per_page=per_page)
# 
#                 response_data['photos'] = [{
#                     "id": photo.id,
#                     "title": photo.title,
#                     "large_square_url": photo.large_square_url,
#                     "medium_url": photo.medium_url,
#                     "url": photo.url
#                 } for photo in page]
# 
#                 response_data['numOfPages'] = paginator.num_pages
#                 response_data['totalOfPhotos'] = paginator.total
# 
#         return JsonResponse(response_data)


# Path: flickr_ckeditor/urls.py
from django.conf.urls import patterns, url
from flickr_ckeditor.views import CkeditorFlickrView

"""
Example URLConf for a flickr ckeditor.

Needs set url ``/ckeditor/flickr/`` url to works this app.

    >>> urlpatterns = patterns(''
    >>>     ...
    >>>     url(r'^ckeditor/flickr/', include('flickr_ckeditor.urls')),
    >>>     ...
    >>> )
"""



urlpatterns = [
    # ckeditor - need be first - don't erase

    url(r'^$', CkeditorFlickrView.as_view(), name='merda-album'),