# Path: adminfiles/settings.py
# ADMINFILES_BROWSER_VIEWS = getattr(settings, 'ADMINFILES_BROWSER_VIEWS',
#                                    ['adminfiles.views.AllView',
#                                     'adminfiles.views.ImagesView',
#                                     'adminfiles.views.AudioView',
#                                     'adminfiles.views.FilesView',
#                                     'adminfiles.views.FlickrView',
#                                     'adminfiles.views.YouTubeView',
#                                     'adminfiles.views.VimeoView'])
# 
# Path: adminfiles/views.py
# def import_browser(path):
#     module, classname = path.rsplit('.', 1)
#     return getattr(__import__(module, {}, {}, [classname]), classname)
# 
# class DisableView(Exception):
#     pass
# 
# class BaseView(TemplateView):
#     template_name = 'adminfiles/uploader/base.html'
# 
#     def get_context_data(self, **kwargs):
#         context = super(BaseView, self).get_context_data(**kwargs)
#         context.update({
#             'browsers': get_enabled_browsers(),
#             'field_id': self.request.GET['field'],
#             'field_type': self.request.GET.get('field_type', 'textarea'),
#             'ADMINFILES_REF_START': settings.ADMINFILES_REF_START,
#             'ADMINFILES_REF_END': settings.ADMINFILES_REF_END,
#             'JQUERY_URL': settings.JQUERY_URL
#         })
# 
#         return context
# 
#     @classmethod
#     def slug(cls):
#         """
#         Return slug suitable for accessing this view in a URLconf.
# 
#         """
#         slug = cls.__name__.lower()
#         if slug.endswith('view'):
#             slug = slug[:-4]
#         return slug
# 
#     @classmethod
#     def link_text(cls):
#         """
#         Return link text for this view.
# 
#         """
#         link = cls.__name__
#         if link.endswith('View'):
#             link = link[:-4]
#         return link
# 
#     @classmethod
#     def url(cls):
#         """
#         Return URL for this view.
# 
#         """
#         return reverse('adminfiles_%s' % cls.slug())
# 
#     @classmethod
#     def check(cls):
#         """
#         Raise ``DisableView`` if the configuration necessary for this
#         view is not active.
# 
#         """
#         pass


from django.core.management.base import NoArgsCommand, CommandError
from adminfiles.settings import ADMINFILES_BROWSER_VIEWS
from adminfiles.views import import_browser, DisableView, BaseView


class Command(NoArgsCommand):
    """
    List all browser views from ADMINFILES_BROWSER_VIEWS and display
    whether each one is enabled or disabled, and why.

    """
    def handle_noargs(self, **options):
        print "Adminfiles browser views available:"
        print
        for browser_path in ADMINFILES_BROWSER_VIEWS:
            try:

# Path: adminfiles/settings.py
# ADMINFILES_BROWSER_VIEWS = getattr(settings, 'ADMINFILES_BROWSER_VIEWS',
#                                    ['adminfiles.views.AllView',
#                                     'adminfiles.views.ImagesView',
#                                     'adminfiles.views.AudioView',
#                                     'adminfiles.views.FilesView',
#                                     'adminfiles.views.FlickrView',
#                                     'adminfiles.views.YouTubeView',
#                                     'adminfiles.views.VimeoView'])
# 
# Path: adminfiles/views.py
# def import_browser(path):
#     module, classname = path.rsplit('.', 1)
#     return getattr(__import__(module, {}, {}, [classname]), classname)
# 
# class DisableView(Exception):
#     pass
# 
# class BaseView(TemplateView):
#     template_name = 'adminfiles/uploader/base.html'
# 
#     def get_context_data(self, **kwargs):
#         context = super(BaseView, self).get_context_data(**kwargs)
#         context.update({
#             'browsers': get_enabled_browsers(),
#             'field_id': self.request.GET['field'],
#             'field_type': self.request.GET.get('field_type', 'textarea'),
#             'ADMINFILES_REF_START': settings.ADMINFILES_REF_START,
#             'ADMINFILES_REF_END': settings.ADMINFILES_REF_END,
#             'JQUERY_URL': settings.JQUERY_URL
#         })
# 
#         return context
# 
#     @classmethod
#     def slug(cls):
#         """
#         Return slug suitable for accessing this view in a URLconf.
# 
#         """
#         slug = cls.__name__.lower()
#         if slug.endswith('view'):
#             slug = slug[:-4]
#         return slug
# 
#     @classmethod
#     def link_text(cls):
#         """
#         Return link text for this view.
# 
#         """
#         link = cls.__name__
#         if link.endswith('View'):
#             link = link[:-4]
#         return link
# 
#     @classmethod
#     def url(cls):
#         """
#         Return URL for this view.
# 
#         """
#         return reverse('adminfiles_%s' % cls.slug())
# 
#     @classmethod
#     def check(cls):
#         """
#         Raise ``DisableView`` if the configuration necessary for this
#         view is not active.
# 
#         """
#         pass


# Path: adminfiles/management/commands/adminfiles_browser_views.py
from django.core.management.base import NoArgsCommand, CommandError
from adminfiles.settings import ADMINFILES_BROWSER_VIEWS
from adminfiles.views import import_browser, DisableView, BaseView



class Command(NoArgsCommand):
    """
    List all browser views from ADMINFILES_BROWSER_VIEWS and display
    whether each one is enabled or disabled, and why.

    """
    def handle_noargs(self, **options):
        print "Adminfiles browser views available:"
        print
        for browser_path in ADMINFILES_BROWSER_VIEWS:
            try:

                view_class = import_browser(browser_path)