Example #1
0
def repository_patterns(app_name, fedora_prefix='', custom_patterns=None):
    urlpatterns = [
        burl('^$',
            fedoralink_ui.views.GenericDetailView.as_view(
                fedora_prefix=fedora_prefix), name="index"),
        burl(r'^(?P<collection_id>[a-fA-F0-9_/-]*)extended_search(?P<parameters>.*)$',
             fedoralink_ui.views.GenericSearchView.as_view(
                 facets=(),
                 orderings=(
                     ('title@en', _('Sort by title (asc)')),
                     ('-title@en', _('Sort by title (desc)')),
                 ),
                 title='Documents',
                 create_button_title='Create a New Document',
                 fedora_prefix=fedora_prefix),
             name='extended_search', verbose_name=_('Search')),

        burl('^(?P<id>.*)/addSubcollection$', staff_member_required(fedoralink_ui.views.GenericSubcollectionCreateView.as_view(
            fedora_prefix=fedora_prefix,
            success_url="repo:detail",
            parent_collection=lambda x: FedoraObject.objects.get(pk=fedora_prefix),
            success_url_param_names=('id',)
        )), name='addSubcollection'),

        burl('^(?P<id>.*)/add$', staff_member_required(fedoralink_ui.views.GenericCreateView.as_view(
            fedora_prefix=fedora_prefix,
            success_url="repo:detail",
            parent_collection=lambda x: FedoraObject.objects.get(pk=fedora_prefix),
            success_url_param_names=('id',)
        ))
             , name='add'),

        burl('^(?P<id>.*)/edit$',
             staff_member_required(fedoralink_ui.views.GenericEditView.as_view(
                 success_url="repo:detail",
                 fedora_prefix=fedora_prefix
             )),
             name="edit"),

        burl('^(?P<id>.*)$',
            fedoralink_ui.views.GenericDetailView.as_view(
                fedora_prefix=fedora_prefix), name="detail"),
    ]

    if custom_patterns:
        urlpatterns.append(custom_patterns)

    return [
        burl(r'^', include(patterns('',
                                   *urlpatterns
                                   ), namespace=app_name, app_name=app_name))
    ]
 def get_urls(self, *args, **kwargs):
     multi_urls = patterns('')
     if self.multiupload_list:
         multi_urls += patterns('',
             url(r'^multiupload/$', staff_member_required(self.admin_upload_view),
                 name=self.get_multiupload_list_view_name())
         )
     if self.multiupload_form:
         multi_urls += patterns('',
             url(r'^(?P<id>\d+)/multiupload/$', staff_member_required(self.admin_upload_view),
                 name=self.get_multiupload_form_view_name()),
         )
     return multi_urls + super(MultiUploadAdmin, self
         ).get_urls(*args, **kwargs)
Example #3
0
    def get_urls(self):
        from django.conf.urls.defaults import patterns, url, include

        urlpatterns = patterns(
            "",
            # filebrowser urls (views)
            url(r"^browse/$", path_exists(self, self.filebrowser_view(self.browse)), name="fb_browse"),
            url(r"^createdir/", path_exists(self, self.filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r"^upload/", path_exists(self, self.filebrowser_view(self.upload)), name="fb_upload"),
            url(
                r"^delete_confirm/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.delete_confirm))),
                name="fb_delete_confirm",
            ),
            url(
                r"^delete/$", file_exists(self, path_exists(self, self.filebrowser_view(self.delete))), name="fb_delete"
            ),
            url(
                r"^detail/$", file_exists(self, path_exists(self, self.filebrowser_view(self.detail))), name="fb_detail"
            ),
            url(
                r"^version/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.version))),
                name="fb_version",
            ),
            # non-views
            url(r"^upload_file/$", staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        )

        return urlpatterns
Example #4
0
    def get_urls(self):
        "URLs for a filebrowser.site"
        try:
            from django.conf.urls import url, patterns
        except ImportError:
            # for Django version less then 1.4
            from django.conf.urls.defaults import url, patterns

        # filebrowser urls (views)
        urlpatterns = patterns(
            "",
            url(r"^browse/$", path_exists(self, filebrowser_view(self.browse)), name="fb_browse"),
            url(r"^createdir/", path_exists(self, filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r"^upload/", path_exists(self, filebrowser_view(self.upload)), name="fb_upload"),
            url(
                r"^delete_confirm/$",
                file_exists(self, path_exists(self, filebrowser_view(self.delete_confirm))),
                name="fb_delete_confirm",
            ),
            url(r"^delete/$", file_exists(self, path_exists(self, filebrowser_view(self.delete))), name="fb_delete"),
            url(r"^detail/$", file_exists(self, path_exists(self, filebrowser_view(self.detail))), name="fb_detail"),
            url(r"^version/$", file_exists(self, path_exists(self, filebrowser_view(self.version))), name="fb_version"),
            url(r"^upload_file/$", staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        )
        return urlpatterns
Example #5
0
 def decorate(view_func):
     def wrapper(request, *args, **kwargs):
         if not request.user.has_perm(permission):
             raise Http404('The requested admin page does not exist.')
         return view_func(request, *args, **kwargs)
     if login:
         wrapper = staff_member_required(wrapper)
     return wrapper
Example #6
0
def page(function, template_name):
    def g(request, *args, **kwargs):
        result = function(request, *args, **kwargs)
        if isinstance(result, dict):
            ctx = extensions.DjangoContext(request)
            return extensions.render_to_response(template_name, result, ctx)
        else:
            return result
    return staff_member_required(g)
Example #7
0
File: views.py Project: delfick/cwf
    def execute(self, target, request, args, kwargs):
        """
            Use the django provided
            `staff_member_required <https://github.com/django/django/blob/master/django/contrib/admin/views/decorators.py>`_
            decorator to ensure only staff members can access any target on this class.
        """

        def view(request, *args, **kwargs):
            return super(StaffView, self).execute(target, request, args, kwargs)

        return staff_member_required(view)(request, *args, **kwargs)
    def get_urls(self):
        "URLs for a filebrowser.site"
        from django.conf.urls import url, patterns

        # filebrowser urls (views)
        return [
            url(r'^browse/$', path_exists(self, filebrowser_view(self.browse)), name="fb_browse"),
            url(r'^createdir/', path_exists(self, filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r'^upload/', path_exists(self, filebrowser_view(self.upload)), name="fb_upload"),
            url(r'^delete_confirm/$', file_exists(self, path_exists(self, filebrowser_view(self.delete_confirm))), name="fb_delete_confirm"),
            url(r'^delete/$', file_exists(self, path_exists(self, filebrowser_view(self.delete))), name="fb_delete"),
            url(r'^detail/$', file_exists(self, path_exists(self, filebrowser_view(self.detail))), name="fb_detail"),
            url(r'^version/$', file_exists(self, path_exists(self, filebrowser_view(self.version))), name="fb_version"),
            url(r'^upload_file/$', staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        ]
Example #9
0
    def get_urls(self):
        try:
            from django.conf.urls import url, patterns, include
        except ImportError:
            # for Django version less then 1.4
            from django.conf.urls.defaults import url, patterns, include

        urlpatterns = patterns('',
            # filebrowser urls (views)
            url(r'^browse/$', path_exists(self, self.filebrowser_view(self.browse)), name="fb_browse"),
            url(r'^createdir/', path_exists(self, self.filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r'^upload/', path_exists(self, self.filebrowser_view(self.upload)), name="fb_upload"),
            url(r'^delete_confirm/$', file_exists(self, path_exists(self, self.filebrowser_view(self.delete_confirm))), name="fb_delete_confirm"),
            url(r'^delete/$', file_exists(self, path_exists(self, self.filebrowser_view(self.delete))), name="fb_delete"),
            url(r'^detail/$', file_exists(self, path_exists(self, self.filebrowser_view(self.detail))), name="fb_detail"),
            url(r'^version/$', file_exists(self, path_exists(self, self.filebrowser_view(self.version))), name="fb_version"),
            # non-views
            url(r'^upload_file/$', staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        )
        return urlpatterns
Example #10
0
from .form import NewsPubForm, NewsHotAddForm, NewsBannerForm
from utils.decorators import ajax_login_required
from django.core.paginator import Paginator
from datetime import datetime, timedelta
from urllib.parse import urlencode


# 必须是员工才可以访问
@staff_member_required(login_url='/authPro/login/')
def index(request):
    return render(request, 'admin/base/index.html')


@method_decorator(
    [csrf_exempt,
     staff_member_required(login_url='/authPro/login/')],
    name='dispatch')
class NewsTagView(View):
    def get(self, request):
        news_tags = NewsTag.objects.filter(is_delete=True).all()
        return render(request,
                      'admin/news/news_tag_manage.html',
                      context={'news_tag': news_tags})

    def post(self, request):
        name = request.POST.get('name')
        if name and bool(name.strip()):
            # exists() 是否存在
            news_tag_exists = NewsTag.objects.filter(name=name).exists()
            if news_tag_exists:
                return json_status.params_error(message='该标签已存在,请不要重复输入')
Example #11
0
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path, reverse_lazy
from django.contrib.auth import views as auth_views
from django.contrib.admin.views.decorators import staff_member_required
from . import views
# from .views import *

app_name = 'polls'

urlpatterns = [
    path('', views.index, name='index'),
    path('search/', views.serchArticles, name='search_article'),
    path('post/create/',
         staff_member_required(views.PostCreate.as_view()),
         name='post_create_url'),
    path('post/<str:slug>/',
         views.PostDetail.as_view(),
         name="post_detail_url"),
    path('post/<str:slug>/update/',
         staff_member_required(views.PostUpdate.as_view()),
         name='post_update_url'),
    path('post/<str:slug>/delete/',
         staff_member_required(views.PostDelete.as_view()),
         name='post_delete_url'),
    path('tags/', views.tags_list, name='tags_list'),
    path('tags/choise/',
         staff_member_required(views.TagChoice.as_view()),
         name='tag_choice_url'),
    path('tag/create/',
         staff_member_required(views.TagCreate.as_view()),
Example #12
0
def custom_staff_member_required(view_func):
    if settings.REQUIRE_VIEW_LOGIN:
        return staff_member_required(view_func)
    else:
        return view_func
Example #13
0
	for w in workers:
		w['load'] = (100 * (w['running_time']/1000))/total_load
		w['last_spawn_str'] = time.ctime(w['last_spawn'])

	jobs = []
        if 'spooler' in uwsgi.opt:
	    spooler_jobs = uwsgi.spooler_jobs()
	    for j in spooler_jobs:
	        jobs.append({'file': j, 'env': uwsgi.parsefile(j)})

	return render_to_response('uwsgi.html', {'masterpid': uwsgi.masterpid(),
						'started_on': time.ctime(uwsgi.started_on),
						'buffer_size': uwsgi.buffer_size,
						'total_requests': uwsgi.total_requests(),
						'numproc': uwsgi.numproc,
						'workers': workers,
						'jobs': jobs,
						}, RequestContext(request, {}))
index = staff_member_required(index)

def reload(request):
	if uwsgi.masterpid() > 0:
		uwsgi.reload()
		request.user.message_set.create(message="uWSGI reloaded")
	else:
		request.user.message_set.create(message="The uWSGI master process is not active")

	return HttpResponseRedirect(reverse(index))

reload = staff_member_required(reload)
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib import messages
from django.http import HttpResponseRedirect
from publications.helpers import parse
from publications.forms import ImportBibtexForm
from publications.models import Publication, Type


def import_bibtex(request):
    tmpl = 'admin/publications/import_bibtex.html'
    title = 'Import BibTex'
    if request.method != 'POST':
        return render(request, tmpl, {
            'title': title,
            'form': ImportBibtexForm(),
        })

    form = ImportBibtexForm(request.POST, request.FILES)
    if form.is_valid():
        s = 's' if form.number_pubs_saved > 1 else ''
        messages.info(request, "%d publication%s successfully created" % (form.number_pubs_saved, s))
        return HttpResponseRedirect('../')

    else:
        return render(request, tmpl, {
            'title': title,
            'form': form,
        })

import_bibtex = staff_member_required(import_bibtex)
Example #15
0
router.register(r"reports", api_views.ReportViewSet)
router.register(r"report", api_views.ReportNestedViewSet)
router.register(r"formats", api_views.FormatViewSet)
router.register(r"filterfields", api_views.FilterFieldViewSet)

urlpatterns = patterns(
    "",
    url(
        "^report/(?P<pk>\d+)/download_file/(?P<filetype>.+)/$",
        views.DownloadFileView.as_view(),
        name="report_download_file",
    ),
    url("^report/(?P<pk>\d+)/check_status/(?P<task_id>.+)/$", views.check_status, name="report_check_status"),
    url("^report/(?P<pk>\d+)/add_star/$", views.ajax_add_star),
    url("^report/(?P<pk>\d+)/create_copy/$", views.create_copy),
    url("^export_to_report/$", views.ExportToReport.as_view(), name="export_to_report"),
    url(r"^api/", include(router.urls)),
    url(r"^api/api-auth/", include("rest_framework.urls", namespace="rest_framework")),
    url(r"^api/related_fields", staff_member_required(api_views.RelatedFieldsView.as_view()), name="related_fields"),
    url(r"^api/fields", staff_member_required(api_views.FieldsView.as_view()), name="fields"),
    url(
        r"^api/report/(?P<report_id>\w+)/generate/",
        staff_member_required(api_views.GenerateReport.as_view()),
        name="generate_report",
    ),
    url("^report/(?P<pk>\d+)/$", views.ReportSPAView.as_view(), name="report_update_view"),
)

if not hasattr(settings, "REPORT_BUILDER_FRONTEND") or settings.REPORT_BUILDER_FRONTEND:
    urlpatterns += patterns("", url(r"^", staff_member_required(views.ReportSPAView.as_view()), name="report_builder"))
        elif file['file_type'] == 'Folder' and file['flag_deletedir'] == True:
            results_var['delete_total'] += 1
    
    return render_to_response('filebrowser/index.html', {
        'dir': dir_name,
        'file_dict': file_dict,
        'results_var': results_var,
        'query': query,
        'counter': counter,
        'settings_var': _get_settings_var(request.META['HTTP_HOST'], path),
        'breadcrumbs': _get_breadcrumbs(_get_query(request.GET), dir_name, ''),
        'title': _(u'FileBrowser'),
        'root_path': URL_HOME,
        'popmode': request.GET.get('pop'),
    }, context_instance=Context(request))
index = staff_member_required(never_cache(index))


def mkdir(request, dir_name=None):
    """
    Make directory
    """
    
    path = _get_path(request, dir_name)
    query = _get_query(request.GET)
    
    if request.method == 'POST':
        form = MakeDirForm(PATH_SERVER, path, request.POST)
        if form.is_valid():
            server_path = os.path.join(PATH_SERVER, path, form.cleaned_data['dir_name'].lower())
            try:
Example #17
0
        settings_modules[settings_module.SITE_ID] = settings_module
    site_list = Site.objects.in_bulk(settings_modules.keys()).values()
    if request.POST:
        form = TemplateValidatorForm(settings_modules, site_list,
                                     data=request.POST)
        if form.is_valid():
            messages.info(request, 'The template is valid.')
    else:
        form = TemplateValidatorForm(settings_modules, site_list)
    return render_to_response('admin/template_validator.html', {
        'title': 'Template validator',
        'form': form,
    }, context_instance=template.RequestContext(request))


template_validator = staff_member_required(template_validator)


class TemplateValidatorForm(forms.Form):
    site = forms.ChoiceField(_('site'))
    template = forms.CharField(
        _('template'), widget=forms.Textarea({'rows': 25, 'cols': 80}))

    def __init__(self, settings_modules, site_list, *args, **kwargs):
        self.settings_modules = settings_modules
        super(TemplateValidatorForm, self).__init__(*args, **kwargs)
        self.fields['site'].choices = [(s.id, s.name) for s in site_list]

    def clean_template(self):
        # Get the settings module. If the site isn't set, we don't raise an
        # error since the site field will.
Example #18
0
        return Post.objects.published().filter(
            locale=self.kwargs['locale'],
        )

blog_detail = require_http_methods(['GET', 'HEAD'])(BlogDetail.as_view())


class BlogDetailPreview(BlogDetail):
    def get_queryset(self):
        return Post.objects.all()


blog_detail_preview = never_cache(
    staff_member_required(
        require_http_methods(['GET', 'HEAD'])(
            BlogDetailPreview.as_view(),
        )
    )
)


class BlogPage(ListView):
    model = Post

    def get_context_data(self, **kwargs):
        context = super(BlogPage, self).get_context_data(**kwargs)
        locale = self.kwargs['locale']
        context['locale'] = locale
        context['rss_feed_url'] = reverse("blog_feed_%s" % locale)
        return context
Example #19
0
        'dir': path,
        'p': p,
        'q': q,
        'page': page,
        'results_var': results_var,
        'counter': counter,
        'query': query,
        'title': _(u'FileBrowser'),
        'settings_var': get_settings_var(),
        'breadcrumbs': get_breadcrumbs(query, path),
        'breadcrumbs_title': ""
    },
                              context_instance=Context(request))


browse = staff_member_required(never_cache(browse))

# mkdir signals
filebrowser_pre_createdir = Signal(providing_args=["path", "dirname"])
filebrowser_post_createdir = Signal(providing_args=["path", "dirname"])


def mkdir(request):
    """
    Make Directory.
    """

    from filebrowser.forms import MakeDirForm

    # QUERY / PATH CHECK
    query = request.GET
Example #20
0
from django.conf.urls import include, url
from django.contrib.admin.views.decorators import staff_member_required
from oauth2_provider.views import ApplicationRegistration

from . import views


urlpatterns = [
    url(r'^applications/$', staff_member_required()(
        views.ApplicationList.as_view()), name='list'),
    url(r'^applications/register/$', staff_member_required()(
        ApplicationRegistration.as_view()), name='register'),
    url(r'', include('oauth2_provider.urls')),
]
Example #21
0
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import patterns, include, url
from django.contrib.admin.views.decorators import staff_member_required

from gallery.views import ImageUploadAddView, ImageUploadListView, QuickActionView

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'artgal.views.home', name='home'),
    # url(r'^artgal/', include('artgal.foo.urls')),
    url(r'^upload/$', ImageUploadAddView.as_view()),
    url(r'^$', ImageUploadListView.as_view()),
    url(r'^mod/(?P<action>\w+)/(?P<pk>\d+)/$', staff_member_required(QuickActionView.as_view())),

    # Uncomment the admin/doc line below to enable admin documentation:
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
class StaffRequiredMixin:
    @method_decorator(staff_member_required())
    def dispatch(self,request,*args,**kwargs):
        return super(StaffRequiredMixin,self).dispatch(request,*args,**kwargs)
Example #23
0
        return HttpResponse(json.dumps([_('error_logfile_notexist')]),
                            mimetype = 'text/html')
    
    file = open(file_record.path, 'r')
    file_position = cache.get('file_position_%s' % file_id);
    file.seek(0, os.SEEK_END)
    if file_position and file_position<=file.tell():
        file.seek(file_position)
    
    content = []
    for line in file:
        content.append('%s' % line.replace('\n','<br/>'))
    
    cache.set('file_position_%s' % file_id, file.tell(), 60*10)
    file.close()
    return HttpResponse(json.dumps(content), mimetype = 'application/json')

@csrf_exempt
def save_to_cliboard(request):
    object = LogsClipboard(name = request.POST['name'],
                           notes = request.POST['notes'],
                           logs = request.POST['logs'],
                           log_file = LogFile.objects\
                           .get(id=int(request.POST['file'])))
    object.save()
    return HttpResponse(_('loglines_saved'), mimetype = 'text/html')
    
  
    
staff_member_required(read_logs)
staff_member_required(get_log_line)
Example #24
0
 def as_view(cls, **initkwargs):
     view = super(AdminRequiredMixin, cls).as_view(**initkwargs)
     return staff_member_required(view)
Example #25
0
                                        ).\
                            extra(select={'month': truncate_date}).\
                            values('formulario__nome', 'month').\
                            annotate(numero_fichas=Count('pk')).\
                            order_by('-month')
	fichas_report = [ dict([
         ('formulario__nome', l['formulario__nome']),
         ('month', datetime.strptime(l['month'].split(' ')[0], '%Y-%m-%d').strftime('%Y%m')),
         ('numero_fichas', l['numero_fichas'])
     ]) for l in fichas_report]
	columns = [dt.strftime('%Y%m') for dt in getMonthList(now, stDate, endDate)]
	forms = Formulario.objects.all()
	rows = [r.nome for r in forms]
	table_data = SortedDict().fromkeys(rows)
	for k in table_data.keys():
		table_data[k] = SortedDict().fromkeys(columns, 0)
	for f in fichas_report:
		table_data[f['formulario__nome']][f['month']] = f['numero_fichas']
	return json_response(table_data)

def json_response(data):
	return HttpResponse(
		simplejson.dumps(data),
		content_type = 'application/javascript; charset=utf8'
	)

add_formulario = staff_member_required(add_formulario)
edit_formulario = staff_member_required(edit_formulario)
log_unidadesaude = staff_member_required(log_unidadesaude)
log_unidadesaude_by_form = staff_member_required(log_unidadesaude_by_form)
Example #26
0
    try:
        return urlresolvers.reverse(admin.site.root, args=[''])
    except urlresolvers.NoReverseMatch:
        return getattr(settings, "ADMIN_SITE_ROOT_URL", "/admin/")


def doc_index(request):
    if not utils.docutils_is_available:
        return missing_docutils_page(request)
    return render_to_response('admin_doc/index.html', {
        'root_path': get_root_path(),
    },
                              context_instance=RequestContext(request))


doc_index = staff_member_required(doc_index)


def bookmarklets(request):
    admin_root = get_root_path()
    return render_to_response('admin_doc/bookmarklets.html', {
        'root_path':
        admin_root,
        'admin_url':
        mark_safe("%s://%s%s" % (request.is_secure() and 'https'
                                 or 'http', request.get_host(), admin_root)),
    },
                              context_instance=RequestContext(request))


bookmarklets = staff_member_required(bookmarklets)
Example #27
0
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def change_status(request, page_id):
    """
    Switch the status of a page.
    """
    perm = PagePermission(request.user).check('change', method='POST')
    if perm and request.method == 'POST':
        page = Page.objects.get(pk=page_id)
        page.status = int(request.POST['status'])
        page.invalidate()
        page.save()
        return HttpResponse(str(page.status))
    raise Http404
change_status = staff_member_required(change_status)

def list_pages_ajax(request, invalid_move=False):
    """Render pages table for ajax function."""
    language = get_language_from_request(request)
    pages = Page.objects.root()
    perms = PagePermission(request.user)
    context = {
        'can_publish': perms.check('publish'),
        'invalid_move':invalid_move,
        'language': language,
        'pages': pages,
    }
    return render_to_response("admin/pages/page/change_list_table.html", 
        context,
        context_instance=RequestContext(request))
Example #28
0
def admin_wrapper(request):
    """
    Wrapper that allows us to properly use the base Django admin site, if needed.
    """
    return staff_member_required(site.index)(request)
Example #29
0
        page = p.page(p.num_pages)
    
    return render_to_response(_template() + 'index.html', {
        'dir': path,
        'p': p,
        'page': page,
        'results_var': results_var,
        'counter': counter,
        'query': query,
        'title': _(u'FileBrowser'),
        'settings_var': get_settings_var(),
        'breadcrumbs': get_breadcrumbs(query, path),
        'breadcrumbs_title': "",
        'is_popup': is_popup
    }, context_instance=Context(request))
browse = staff_member_required(never_cache(browse))


# mkdir signals
filebrowser_pre_createdir = Signal(providing_args=["path", "dirname"])
filebrowser_post_createdir = Signal(providing_args=["path", "dirname"])

def mkdir(request):
    """
    Make Directory.
    """
    
    from filebrowser.forms import MakeDirForm
    
    # QUERY / PATH CHECK
    query = request.GET
Example #30
0
from django.urls import path
from . import views
from django.contrib.auth import views as auth_views
from django.contrib.admin.views.decorators import staff_member_required

urlpatterns = [
    path('login', auth_views.LoginView.as_view(), name='login'),
    path('logout', auth_views.LogoutView.as_view(), name='logout'),
	path('home', views.index, name='home'),
    path('registroAlumno', staff_member_required(views.registroAlumno), name='registroAlumno'),
    path('AdministradorArchivo', views.AdministradorArchivo, name='AdministradorArchivo'),


]
    ApiRequestStatusView, ApiRequestView, ApiTosView, CatalogEditView,
    CatalogListView, CatalogPreviewView, CatalogSearchView)

app_name = 'api_admin'
urlpatterns = (
    url(r'^status/$',
        api_access_enabled_or_404(
            login_required(ApiRequestStatusView.as_view())),
        name="api-status"),
    url(r'^terms-of-service/$',
        api_access_enabled_or_404(ApiTosView.as_view()),
        name="api-tos"),
    url(
        r'^catalogs/preview/$',
        staff_member_required(api_access_enabled_or_404(
            CatalogPreviewView.as_view()),
                              login_url='dashboard',
                              redirect_field_name=None),
        name='catalog-preview',
    ),
    url(
        r'^catalogs/user/(?P<username>[\w.@+-]+)/$',
        staff_member_required(api_access_enabled_or_404(
            CatalogListView.as_view()),
                              login_url='dashboard',
                              redirect_field_name=None),
        name='catalog-list',
    ),
    url(
        r'^catalogs/(?P<catalog_id>\d+)/$',
        staff_member_required(api_access_enabled_or_404(
            CatalogEditView.as_view()),
Example #32
0
from __future__ import absolute_import

from django.urls import re_path
from django.contrib.admin.views.decorators import staff_member_required
from django.views.decorators.cache import never_cache

from . import views

urlpatterns = [
    re_path(r"^upload/", staff_member_required(views.upload), name="ckeditor_upload"),
    re_path(
        r"^browse/",
        never_cache(staff_member_required(views.browse)),
        name="ckeditor_browse",
    ),
]
Example #33
0
from django.contrib.auth import views as auth_views

# Websup URL Configuration
urlpatterns = [
    url(r'^admin/', admin.site.urls),

    # Clientapp
    url(r'^$', login_required(Clientapp.views.dashboard), name="clientapp_dashboard"),
    url(r'^send$', login_required(Clientapp.views.send), name="clientapp_send"),
    url(r'^report$', login_required(Clientapp.views.report), name="clientapp_report"),
    url(r'^contactus$', login_required(Clientapp.views.contactus), name="clientapp_contactus"),

    # Login
    url(r'^user/login/$', auth_views.login, {'template_name': 'registration/login.html'}, name='auth_login'),
    url(r'^user/logout/$', login_required(auth_views.logout), {'template_name': 'registration/logout.html'}, name='auth_logout'),
    url(r'^user/changepassword/$', login_required(auth_views.password_change), {'post_change_redirect': 'password_change_done'}, name='password_change'),
    url(r'^user/passwordchanged/$', login_required(auth_views.password_change_done), name='password_change_done'),

    # Api
    url(r'^admin/whatsapp$', staff_member_required(Clientapp.views.api_mainpage), name='whatsapp_gui'),
    url(r'^admin/whatsapp/(?P<id>[\d]+)/$', staff_member_required(Clientapp.views.api_mainpage), name='whatsapp_gui'),
    url(r'^api/(?P<command>[a-z_]+)/$', staff_member_required(Clientapp.views.api), name="whatsapp_api"),
    url(r'^admin/adminReport$', staff_member_required(Clientapp.views.adminReport), name='whatsapp_report'),

]


if settings.DEBUG is True:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #34
0
from __future__ import absolute_import

import django
from django.conf.urls import url
from django.contrib.admin.views.decorators import staff_member_required
from django.views.decorators.cache import never_cache

from . import views

if django.VERSION >= (1, 8):
    urlpatterns = [
        url(r'^upload/',
            staff_member_required(views.upload),
            name='ckeditor_upload'),
        url(r'^browse/',
            never_cache(staff_member_required(views.browse)),
            name='ckeditor_browse'),
        url(r'^browse_thumbnail/',
            never_cache(staff_member_required(views.browse_thumbnail)),
            name='ckeditor_browse_thumbnail'),
    ]
else:
    from django.conf.urls import patterns
    urlpatterns = patterns(
        '',
        url(r'^upload/',
            staff_member_required(views.upload),
            name='ckeditor_upload'),
        url(r'^browse/',
            never_cache(staff_member_required(views.browse)),
            name='ckeditor_browse'),
Example #35
0
def add(request, position_name, type, id):

    position = get_object_or_404(Position, name__iexact=position_name)
    ctype = get_object_or_404(ContentType, pk=type)

    obj = ctype.get_object_for_this_type(id=id)
    if position not in Position.objects.get_applicable(obj):
        return HttpResponseForbidden(
            "The object cannot be added to this position.")

    Position.objects.add_object(position, obj)

    return HttpResponseRedirect(get_admin_url(obj))


add = staff_member_required(add)


def remove(request, position_name, type, id):
    """
    Resolves the object by the specified content type and id, and removes it
    from the specified Position if it has already been added.
    """
    next = request.GET.get('next', '')
    position = get_object_or_404(Position, name__iexact=position_name)

    ctype = get_object_or_404(ContentType, pk=type)
    obj = ctype.get_object_for_this_type(id=id)

    Position.objects.remove_object(position=position, obj=obj)
Example #36
0
mass_change_selected.short_description = _('Mass Edit')


def mass_change_view(request,
                     app_name,
                     model_name,
                     object_ids,
                     admin_site=None):
    if object_ids.startswith("session-"):
        object_ids = request.session.get(object_ids)
    model = get_model(app_name, model_name)
    ma = MassAdmin(model, admin_site or admin.site)
    return ma.mass_change_view(request, object_ids)


mass_change_view = staff_member_required(mass_change_view)


def get_formsets(model, request, obj=None):
    try:  # Django>=1.9
        return [f for f, _ in model.get_formsets_with_inlines(request, obj)]
    except AttributeError:
        return model.get_formsets(request, obj)


class MassAdmin(admin.ModelAdmin):
    def __init__(self, model, admin_site):
        try:
            self.admin_obj = admin_site._registry[model]
        except KeyError:
            raise Exception('Model not registered with the admin site.')
Example #37
0
from django.contrib.admin.views.decorators import staff_member_required
import vobject
from vobject.vcard import *
from django.shortcuts import render_to_response
import StringIO
from django.http import HttpResponse
from django.core.servers.basehttp import FileWrapper


def vcf_file_view(request, contact_set):

    vcf_file_content = ""

    for c in contact_set:

        vcf_file_content = vcf_file_content + c.exportTo('vCard')

    theFile = StringIO.StringIO()

    theFile.write(vcf_file_content)
    theFile.seek(0)

    response = HttpResponse(vcf_file_content,
                            mimetype='application/force-download')
    response['Content-Disposition'] = 'attachment; filename=vcf_file.vcf'

    return response


vcf_file_view = staff_member_required(vcf_file_view)
Example #38
0
     RedirectView.as_view(permanent=False, url='/settings/languages'),
     name="settings"),
 url(r'^languages$',
     LanguagesSettingsView.as_view(),
     name="settings-languages"),
 url(r'^translation-platforms$',
     TransPlatformSettingsView.as_view(),
     name="settings-trans-platforms"),
 url(
     r'^product/(?P<stream_slug>\w+)/',
     include([
         url(r'^releases$',
             StreamBranchesSettingsView.as_view(),
             name="settings-stream-branches"),
         url(r'^releases/new$',
             staff_member_required(NewReleaseBranchView.as_view()),
             name="settings-stream-branches-new")
     ])),
 url(r'^products$',
     ReleaseStreamSettingsView.as_view(),
     name="settings-release-streams"),
 url(r'^packages/new$',
     login_required(NewPackageView.as_view(),
                    login_url="oidc_authentication_init"),
     name="settings-packages-new"),
 url(r'^packages/export/(?P<format>[\w+]+)$',
     export_packages,
     name="packages-export"),
 url(r'^packages$', PackageSettingsView.as_view(),
     name="settings-packages"),
 url(r'^notification$',
Example #39
0
 def as_view(cls,**initkwargs):
     view=super(AdminRequiredMixin,cls).as_view(**initkwargs)
     return staff_member_required(view)
Example #40
0
        TemplateView.as_view(template_name="settings/notification.html"),
        name="settings-notification"),
]

ajax_urls = [
    url(r'^schedule-job$', schedule_job, name="ajax-schedule-job"),
    url(r'^graph-data$', graph_data, name="ajax-graph-data"),
    url(r'^tabular-data$', tabular_data, name="ajax-tabular-data"),
    url(r'^refresh-package$', refresh_package, name="ajax-refresh-package"),
    url(r'^release-graph$', release_graph, name="ajax-release-graph"),
    url(r'^generate-reports$', generate_reports, name="ajax-releases-report"),
    url(r'^read-file-logs$', read_file_logs, name="ajax-read-logs"),
    url(r'^build-tags$', get_build_tags, name="ajax-build-tags"),
    url(r'^job-template$', job_template, name="ajax-job-template"),
    url(r'^change-lang-status$',
        staff_member_required(change_lang_status),
        name="ajax-change-lang-status"),
]

coverage_urls = [
    url(r'^$', GraphRulesSettingsView.as_view(), name="settings-graph-rules"),
    url(r'^view/(?P<coverage_rule>[\w\-\+]+)$',
        TransCoverageView.as_view(),
        name="custom-graph"),
    url(r'^new$',
        login_required(NewGraphRuleView.as_view(), login_url=LOGIN_URL),
        name="settings-graph-rules-new"),
    url(r'^edit/(?P<slug>[\w-]+)$',
        login_required(UpdateGraphRuleView.as_view(), login_url=LOGIN_URL),
        name="graph-rule-update"),
    url(r'^remove/(?P<slug>[\w-]+)$',
Example #41
0
    else:
        last_position = request.session.get("file_position_%s" % file_id)

        file.seek(0, os.SEEK_END)
        if last_position and last_position <= file.tell():
            file.seek(last_position)

        for line in file:
            content.append("%s" % line.replace("\n", "<br/>"))

    request.session["file_position_%s" % file_id] = file.tell()
    file.close()
    return HttpResponse(json.dumps(content), mimetype="application/json")


@csrf_exempt
def save_to_cliboard(request):
    object = LogsClipboard(
        name=request.POST["name"],
        notes=request.POST["notes"],
        logs=request.POST["logs"],
        log_file=LogFile.objects.get(id=int(request.POST["file"])),
    )
    object.save()
    return HttpResponse(_("loglines_saved"), mimetype="text/html")


staff_member_required(read_logs)

########NEW FILE########
Example #42
0
 def as_view(self, *args, **kwargs):
     view = super(StaffRequiredMixin, self).as_view(*args, **kwargs)
     return staff_member_required(view)
Example #43
0
urlpatterns = (
    url(
        r'^status/$',
        api_access_enabled_or_404(login_required(ApiRequestStatusView.as_view())),
        name="api-status"
    ),
    url(
        r'^terms-of-service/$',
        api_access_enabled_or_404(ApiTosView.as_view()),
        name="api-tos"
    ),
    url(
        r'^catalogs/preview/$',
        staff_member_required(
            api_access_enabled_or_404(CatalogPreviewView.as_view()),
            login_url='dashboard',
            redirect_field_name=None
        ),
        name='catalog-preview',
    ),
    url(
        r'^catalogs/user/(?P<username>[\w.@+-]+)/$',
        staff_member_required(
            api_access_enabled_or_404(CatalogListView.as_view()),
            login_url='dashboard',
            redirect_field_name=None
        ),
        name='catalog-list',
    ),
    url(
        r'^catalogs/(?P<catalog_id>\d+)/$',
Example #44
0
    url(r'^locknum/$', sale_buyer_required(views.productsku_quantity_view), name="skuquantity_lock"),
    url(r'^pdetail/(?P<pk>[0-9]+)/$', views.ProductDetailView.as_view(), name="pdetail_for_phone"),

    # order urls
    url(r'^orderbuy/pay.htm$', cache_page(24 * 60 * 60)(TemplateView.as_view(template_name="pay/pay.html"))),
    url(r'^payresult/$', sale_buyer_required(views.PayResultView.as_view()), name="user_payresult"),

    # address urls
    url(r'^addr/list/$', sale_buyer_required(views.AddressList.as_view()), name="address_list"),
    url(r'^addr/$', sale_buyer_required(views.UserAddressDetail.as_view()), name="address_ins"),
    url(r'^add_supplier_addr/$', views.add_supplier_addr, name="add_supplier_addr"),
    url(r'^get_supplier_name/$', views.get_supplier_name, name="get_supplier_name"),
    url(r'^addr/area/$', cache_page(24 * 60 * 60)(views.DistrictList.as_view()), name="address_area"),

    # envelop urls
    url(r'^envelop/confirm/$', staff_member_required(views.EnvelopConfirmSendView.as_view()), name="envelop_confirm"),
    url(r'^budget/send_envelop/$', views.SendBudgetEnvelopAPIView.as_view(), name="envelop_send"),

    # profile urls
    url(r'^login/$', views.flashsale_login, name="flashsale_login"),

    url(r'^order_flashsale/$', views.order_flashsale, name="order_flashsale"),
    url(r'^time_rank/(?P<time_id>\d+)/$', views.time_rank, name="time_rank"),
    url(r'^sale_state/(?P<state_id>\d+)/$', views.sale_state, name="sale_state"),
    url(r'^refund_state/(?P<state_id>\d+)/$', views.refund_state, name="refund_state"),
    url(r'^refunding_state/(?P<state_id>\d+)/$', views.refunding_state, name="refunding_state"),

    url(r'^preorder_flashsale/$', views.preorder_flashsale, name="preorder_flashsale"),
    url(r'^nextorder_flashsale/$', views.nextorder_flashsale, name="nextorder_flashsale"),
    url(r'^search_flashsale/$', views.search_flashsale, name="search_flashsale"),
    url(r'^aggregeta_product/$', csrf_exempt(views.AggregateProductView.as_view()), name="aggregate_product"),
 def filebrowser_view(self, view):
     return staff_member_required(never_cache(view))
Example #46
0
import string


def lateLoans(request):
    return render_to_response(
        'admin/library/lateloans.html',
        {
            'loans':
            Loan.objects.filter(returned__isnull=True,
                                due__lt=datetime.date.today())
        },
        RequestContext(request, {}),
    )


lateLoans = staff_member_required(lateLoans)


def makePublisher(request):
    name = request.GET.get('value', '')
    a = Publisher.objects.filter(name=name)
    if (len(a)):
        message = "The publisher is already in the database (" + name + ")! We just added a link to those guys !"
        id = a[0].id
    else:
        pub = Publisher(name=name)
        pub.save()
        id = pub.id
        message = "The publisher didn't exist in the database (" + name + ")! We just created it (id:" + str(
            id) + ") !"
    results = {'message': message, 'id': id}
Example #47
0
from django.conf.urls.defaults import *
from django.contrib.admin.views.decorators import staff_member_required
from django_mlds.flatblocks.views import edit

urlpatterns = patterns('',
    url('^edit/(?P<pk>\d+)/$', staff_member_required(edit), name='flatblocks-edit')
)
from django.urls import path
from django.contrib.admin.views.decorators import staff_member_required
from .views import AdminExport

view = staff_member_required(AdminExport.as_view())

urlpatterns = [
    path('export/', view, name="export"),
]
Example #49
0
    name = 'my site'

def get_root_path():
    from django.contrib import admin
    try:
        return urlresolvers.reverse(admin.site.root, args=[''])
    except urlresolvers.NoReverseMatch:
        return getattr(settings, "ADMIN_SITE_ROOT_URL", "/admin/")

def doc_index(request):
    if not utils.docutils_is_available:
        return missing_docutils_page(request)
    return render_to_response('admin_doc/index.html', {
        'root_path': get_root_path(),
    }, context_instance=RequestContext(request))
doc_index = staff_member_required(doc_index)

def bookmarklets(request):
    admin_root = get_root_path()
    return render_to_response('admin_doc/bookmarklets.html', {
        'root_path': admin_root,
        'admin_url': mark_safe("%s://%s%s" % (request.is_secure() and 'https' or 'http', request.get_host(), admin_root)),
    }, context_instance=RequestContext(request))
bookmarklets = staff_member_required(bookmarklets)

def template_tag_index(request):
    if not utils.docutils_is_available:
        return missing_docutils_page(request)

    load_all_installed_template_libraries()
Example #50
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# If you want to use this software an plan to distribute a
# proprietary application in any way, and you are not licensing and
# distributing your source code under GPL, you probably need to
# purchase a commercial license of the product.  More info about
# licensing options is available at:
#
#   http://morfeo-project.org/
#

from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext, Context
from django.template.loader import get_template
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.contrib.admin.views.decorators import staff_member_required


def index(request, user_name=None):
    """ vista demostrador """
    return render_to_response('index.html', {},
                              context_instance=RequestContext(request))


index = staff_member_required(index)
Example #51
0
def admin_required(func):
    ## return login_required(staff_member_required(func))
    return login_required(aaf_active_or_else_required(staff_member_required(func)))
Example #52
0
        content = [line.replace('\n', '<br/>') for line in content]
    else:
        last_position = request.session.get('file_position_%s' % file_id)

        file.seek(0, os.SEEK_END)
        if last_position and last_position <= file.tell():
            file.seek(last_position)

        for line in file:
            content.append('%s' % line.replace('\n', '<br/>'))

    request.session['file_position_%s' % file_id] = file.tell()
    file.close()
    return HttpResponse(json.dumps(content), mimetype='application/json')


@csrf_exempt
def save_to_cliboard(request):
    object = LogsClipboard(name = request.POST['name'],
                           notes = request.POST['notes'],
                           logs = request.POST['logs'],
                           log_file = LogFile.objects\
                           .get(id=int(request.POST['file'])))
    object.save()
    return HttpResponse(_('loglines_saved'), mimetype='text/html')


staff_member_required(read_logs)

########NEW FILE########
 def filebrowser_view(self, view):
     "Only let staff browse the files"
     return staff_member_required(never_cache(view))
from django.contrib.admin.views.decorators import staff_member_required

urlpatterns = patterns(
    '',
    url(r'^admin/', include(admin.site.urls)),
    # This is the URL Varnish will ping to check the server health.
    url(r'^app_status/$', 'toolbox.views.app_status', name='status'),
    # All the URLs from our signal project
    url(r'^', include('soundtracker.urls')),
)

if settings.DEBUG:
    urlpatterns += patterns(
        'django.views.static',
        url(r'^static/(?P<path>.*)$', 'serve', {
            'document_root': settings.STATIC_ROOT,
            'show_indexes': True,
        }),
        url(r'^media/(?P<path>.*)$', 'serve', {
            'document_root': settings.MEDIA_ROOT,
            'show_indexes': True,
        }),
    )

if settings.PRODUCTION:
    urlpatterns += patterns(
        '',
        url(r'^munin/(?P<path>.*)$', staff_member_required(static_serve), {
            'document_root': settings.MUNIN_ROOT,
        }))
Example #55
0
sitemaps = {
    'blogs_news': sitemaps.BlogNewsXML,
    'projects_news': sitemaps.ProjectsNewsXML,
    'authors_details': sitemaps.AuthorXML,
}

urlpatterns = patterns('',
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.MEDIA_ROOT,
        }),
    url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.STATIC_ROOT,
        }),
    url(r'^$', HomeView.as_view(), name='home'),
    url(r'^contact/$', ContactFormView, name='contact'),
    url(r'^admin/topics/all/$', staff_member_required(TopicsListView.as_view()), name='topics_list'),
    url(r'^admin/', include(admin.site.urls)),

    url(r'^feeds/all/view/$', FeedsListView.as_view(), name='rss_list'),
    url(r'^feeds/rss/$', feeds.LatestNewsFeed(), name='rss_feed'),
    url(r'^feeds/(?P<project_slug>.+)/rss/$', feeds.ProjectNewsFeed(),name='project_rss'),


    url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.index',
        {'sitemaps': sitemaps}),
    url(r'^sitemap-(?P<section>.+).xml$',
        'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': sitemaps}),
    url(r'^summernote/', include('django_summernote.urls')),
    url(r'^imagefit/', include('imagefit.urls')),
    url(r'^search/', include('haystack.urls')),
fully_decorated = vary_on_headers('Accept-language')(fully_decorated)
fully_decorated = vary_on_cookie(fully_decorated)

# django.views.decorators.cache
fully_decorated = cache_page(60*15)(fully_decorated)
fully_decorated = cache_control(private=True)(fully_decorated)
fully_decorated = never_cache(fully_decorated)

# django.contrib.auth.decorators
# Apply user_passes_test twice to check #9474
fully_decorated = user_passes_test(lambda u:True)(fully_decorated)
fully_decorated = login_required(fully_decorated)
fully_decorated = permission_required('change_world')(fully_decorated)

# django.contrib.admin.views.decorators
fully_decorated = staff_member_required(fully_decorated)

# django.utils.functional
fully_decorated = memoize(fully_decorated, {}, 1)
fully_decorated = allow_lazy(fully_decorated)
fully_decorated = lazy(fully_decorated)


class DecoratorsTest(TestCase):

    def test_attributes(self):
        """
        Tests that django decorators set certain attributes of the wrapped
        function.
        """
        # Only check __name__ on Python 2.4 or later since __name__ can't be
Example #57
0
def change_status(request, page_id):
    """
    Switch the status of a page
    """
    if request.method == 'POST':
        page = Page.objects.get(pk=page_id)
        if page.has_publish_permission(request):
            if page.status == Page.DRAFT:
                page.status = Page.PUBLISHED
            elif page.status == Page.PUBLISHED:
                page.status = Page.DRAFT
            page.save()    
            return HttpResponse(unicode(page.status))
    raise Http404
change_status = staff_member_required(change_status)

def change_innavigation(request, page_id):
    """
    Switch the in_navigation of a page
    """
    if request.method == 'POST':
        page = Page.objects.get(pk=page_id)
        if page.has_page_permission(request):
            if page.in_navigation:
                page.in_navigation = False
                val = 0
            else:
                page.in_navigation = True
                val = 1
            page.save()
Example #58
0
def filebrowser_view(view):
    "Only let staff browse the files"
    return staff_member_required(never_cache(view))
Example #59
0
    if request.GET.get('query', False):
        # create search form with GET variables if given
        search_form = form_class(request.GET)

        if search_form.is_valid():
            query = search_form.cleaned_data['query']

            # perform actual search
            search_results = Page.objects.search(request.user, query, language)
            page_ids = [res['id'] for res in search_results.values('id')]
            search_results_ml = Page.objects.search(request.user, query).exclude(id__in=page_ids)

            # update context to contain query and search results
            context.update({
                'search_results': search_results,
                'search_results_ml': search_results_ml,
                'query': query,
            })
    else:
        search_form = form_class()

    context.update({
        'search_form': search_form,
    })
    return render_to_response(template_name, extra_context,
        context_instance=RequestContext(request, context))

if REQUIRE_LOGIN:
    handler = staff_member_required(handler)
    search = staff_member_required(search)
Example #60
0
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def change_status(request, page_id):
    """
    Switch the status of a page.
    """
    perm = request.user.has_perm('pages.change_page')
    if perm and request.method == 'POST':
        page = Page.objects.get(pk=page_id)
        page.status = int(request.POST['status'])
        page.invalidate()
        page.save()
        return HttpResponse(str(page.status))
    raise Http404
change_status = staff_member_required(change_status)

def list_pages_ajax(request, invalid_move=False):
    """Render pages table for ajax function."""
    language = get_language_from_request(request)
    pages = Page.objects.root()
    context = {
        'can_publish': request.user.has_perm('pages.can_publish'),
        'invalid_move':invalid_move,
        'language': language,
        'pages': pages,
    }
    return render_to_response("admin/pages/page/change_list_table.html", 
        context,
        context_instance=RequestContext(request))
list_pages_ajax = staff_member_required(list_pages_ajax)