예제 #1
0
        if 'json' in self.request.GET:
            return HttpResponse(
                json.dumps(
                    {
                        'fields': [self.field_name],
                        'data': self.get_choices()
                    },
                    cls=DjangoJSONEncoder))
        else:
            return super(AutocompleteEqualFilterFormView,
                         self).render_to_response(context, **response_kwargs)


class DateFilterFormView(FilterFormView):
    form_class = DateFilterForm


class DateRangeFilterFormView(FilterFormView):
    form_class = DateRangeFilterForm


class DateChoiceFilterFormView(FilterFormView):
    form_class = DateChoiceFilterForm


ui.register(EqualFilterFormView)
ui.register(DateFilterFormView)
ui.register(DateRangeFilterFormView)
ui.register(DateChoiceFilterFormView)
ui.register(AutocompleteEqualFilterFormView)
예제 #2
0
from ui.views.gridview.filters.fields import DateFieldFilter
from ui.views.viewset import AdminPageViewSet
from ui import ui


class PersonExampleAdmin(AdminPageViewSet):
    model = Person
    base_url = 'person'
    state_name = 'person'
    paginate_by = 5
    render_form = True
    list_display = [
        'id', 'first_name', 'last_name', 'date', 'email', 'age', 'sex',
        'revenue'
    ]
    list_filter = [
        'first_name',
        'last_name',
        'sex',
        (DateFieldFilter, 'date'),
    ]
    list_display_links = ['last_name']
    list_editable = ['first_name', 'date']
    title = 'Person example'
    icon = 'fa fa-tasks'
    panel_title = 'Person example'
    use_menu_template = 'state'


ui.register(PersonExampleAdmin)
예제 #3
0
        query = request.GET.get('query', '')
        self.queryset = session.load_queryset(self.request, kwargs['queryset'])
        self.search_fields = kwargs['search_fields'].split(',')
        self.display_fields = kwargs['display_fields'].split(',')
        self.extra_params = kwargs['extra_params'].split(',')
        self.search_string = query
        if self.extra_params:
            for arg in self.extra_params:
                if request.GET.get(arg, None):
                    if self.extra_params_values is None:
                        self.extra_params_values = {}
                    self.extra_params_values[arg] = request.GET[arg]

        return HttpResponse(self.serialize(self.get_data()))

    @classonlymethod
    def urlpattern(cls):
        return r'^%s/%s/(?P<queryset>[a-zA-Z0-9]+)/(?P<search_fields>[a-zA-Z_,]+)/(?P<display_fields>[a-zA-Z_,]+)/(?P<extra_params>[a-zA-Z_,]+)$' % (
            str(cls.__module__), cls.__name__.lower())

    def get_url(self):
        self._queryset_key = session.save_queryset(self.request, self.queryset)
        return reverse(self.url_name(), kwargs={'queryset': self._queryset_key,
                                                'search_fields': ','.join(self.search_fields),
                                                'display_fields': ','.join(self.display_fields or self.search_fields),
                                                'extra_params': ','.join(self.extra_params) if self.extra_params else '__none__' }
                       )


ui.register(AutocompleteView)
예제 #4
0
from ui import ui
from ui.dashboard.todo import ToDoListView
from ui.views.auth import LoginView
from ui.views.module import DashboardMenuView

ui.register(LoginView)
ui.register(DashboardMenuView)
# ui.register(CompanyFileBrowserAdminPage)
ui.register(ToDoListView)
예제 #5
0
    list_display = [('notification__level', 'Level'),
                    ('notification__timestamp', 'Date'),
                    ('notification__title', 'Title'),
                    ('notification__message', 'Message')]

    list_order = [
        'notification__level',
        'notification__timestamp',
    ]

    def get_queryset(self):
        return super(NotificationGridView,
                     self).get_queryset().filter(recipient=self.request.user)


class NotificationAdminPage(AdminPage):
    template_name = 'ui/notifications.html'
    title = 'Notifications'
    icon = 'fa fa-bell-o'
    panel_title = 'All notifications'

    def get_context_data(self, **kwargs):
        context = super(NotificationAdminPage, self).get_context_data(**kwargs)
        context['grid_view'] = NotificationGridView.rendered_content(
            self.request)
        return context


ui.register(NotificationAdminPage)
ui.register(NotificationGridView)
예제 #6
0
                     self).render_to_response(context, **response_kwargs)


class FileBrowserUploadDialog(FileBrowserAdminPage):
    template_name = 'ui/filebrowser/upload_dialog.html'

    @method_decorator(csrf_exempt)
    def dispatch(self, *args, **kwargs):
        return super(FileBrowserUploadDialog, self).dispatch(*args, **kwargs)

    def post(self, request, *args, **kwargs):
        dir = self.request.GET.get('dir', '')
        if dir == 'undefined':
            dir = ''
        dir = os.path.join(get_directory(), dir)
        file = request.FILES['file']
        if not file_filter(self.request, UPLOAD, dir, file.name):
            return self.serialize({'answer': 'Permissions denied'})
        f = open(os.path.join(dir, file.name), 'wb')
        f.write(file.read())
        f.close()
        return self.serialize({'answer': 'success'})


ui.register(FileBrowserGridView)
ui.register(FileBrowserDialog)
ui.register(FileBrowserUploadDialog)
ui.register(FileBrowserNewFolderDialog)
ui.register(FileBrowserRenameDialog)
ui.register(FileBrowserRemoveDialog)