# Path: django_flickr_gallery/admin/forms.py
# class PhotosetAdminForm(forms.ModelForm):
#     def __init__(self, *args, **kwargs):
#         super(PhotosetAdminForm, self).__init__(*args, **kwargs)
# 
#         # set choices with flickr albums
#         self.fields['photoset_id'].widget = forms.Select(choices=photosets_as_choices())
# 
#     class Meta:
#         model = PhotosetModel
#         fields = '__all__'
# 
# Path: django_flickr_gallery/utils/date.py
# def parse_unix_datetime(str_value):
#     if isinstance(str_value, (str, bytes)):
#         str_value = int(str_value)
# 
#     time_struct = time.localtime(int(str_value))
#     return datetime.datetime(
#         year=time_struct.tm_year,
#         month=time_struct.tm_mon,
#         day=time_struct.tm_mday,
#         hour=time_struct.tm_hour,
#         minute=time_struct.tm_min,
#         second=time_struct.tm_sec)


from django.contrib import admin
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django_flickr_gallery.admin.forms import PhotosetAdminForm
from django_flickr_gallery.utils.date import parse_unix_datetime


def display_attr(func, short_description=None, boolean=False):
    def wrap(*args, **kwargs):
        return func(*args, **kwargs)

    wrap.short_description = short_description
    wrap.boolean = boolean
    return wrap


class PhotosetAdmin(admin.ModelAdmin):
    list_display = ['primary', 'title', 'description', 'count', 'last_update']

# Path: django_flickr_gallery/admin/forms.py
# class PhotosetAdminForm(forms.ModelForm):
#     def __init__(self, *args, **kwargs):
#         super(PhotosetAdminForm, self).__init__(*args, **kwargs)
# 
#         # set choices with flickr albums
#         self.fields['photoset_id'].widget = forms.Select(choices=photosets_as_choices())
# 
#     class Meta:
#         model = PhotosetModel
#         fields = '__all__'
# 
# Path: django_flickr_gallery/utils/date.py
# def parse_unix_datetime(str_value):
#     if isinstance(str_value, (str, bytes)):
#         str_value = int(str_value)
# 
#     time_struct = time.localtime(int(str_value))
#     return datetime.datetime(
#         year=time_struct.tm_year,
#         month=time_struct.tm_mon,
#         day=time_struct.tm_mday,
#         hour=time_struct.tm_hour,
#         minute=time_struct.tm_min,
#         second=time_struct.tm_sec)


# Path: django_flickr_gallery/admin/photoset.py
from django.contrib import admin
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django_flickr_gallery.admin.forms import PhotosetAdminForm
from django_flickr_gallery.utils.date import parse_unix_datetime



def display_attr(func, short_description=None, boolean=False):
    def wrap(*args, **kwargs):
        return func(*args, **kwargs)

    wrap.short_description = short_description
    wrap.boolean = boolean
    return wrap


class PhotosetAdmin(admin.ModelAdmin):
    list_display = ['primary', 'title', 'description', 'count', 'last_update']

    form = PhotosetAdminForm