from django.conf.urls import include, url from django.urls import path from django.conf import settings from django.conf.urls.static import static from django.views.generic import RedirectView from django.contrib import admin from filebrowser.sites import site from filebrowser.sites import FileBrowserSite from django.core.files.storage import DefaultStorage # django_version=="2.1" urlpatterns = [ path('test-history/', site.urls), path('admin/', admin.site.urls), path('cws/', include('coverage_websys_func.urls')), path('', RedirectView.as_view(url='/cws', permanent=True)), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # config admin page admin.site.site_header = 'Coverage - Test Web System Admin' admin.site.index_title = 'coverage - test web system ' admin.site.site_title = 'administration' # c_site = FileBrowserSite(name='FB', app_name='filebrowser', storage=DefaultStorage())
# -*- coding: utf-8 -*- from django.conf import settings from django.conf.urls import url from django.conf.urls.static import * from django.contrib.staticfiles.urls import static from django.contrib import admin from filebrowser.sites import FileBrowserSite from crm.views import * from accounting.views import * from django.core.files.storage import DefaultStorage site = FileBrowserSite(name="filebrowser", storage=DefaultStorage()) customsite = FileBrowserSite(name='custom_filebrowser', storage=DefaultStorage()) customsite.directory = "uploads/" admin.autodiscover() urlpatterns = [ url(r'^admin/filebrowser/', customsite.urls), url(r'^admin/', admin.site.urls), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls.static import * from django.contrib.staticfiles.urls import static from django.contrib import admin from filebrowser.sites import FileBrowserSite from django.core.files.storage import DefaultStorage from django.conf.urls import include site = FileBrowserSite(name="filebrowser", storage=DefaultStorage()) customsite = FileBrowserSite(name='custom_filebrowser', storage=DefaultStorage()) customsite.directory = "media/uploads/" admin.autodiscover() urlpatterns = [ url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^admin/filebrowser/', customsite.urls), url(r'^admin/', admin.site.urls), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
def fileobject_is_used_by(self, fileobject): if fileobject.filetype == 'Folder': return [] filename = fileobject.name used_by = [] for classname, attr_names in settings.IMAGE_FIELDS: for attr_name in attr_names: used_by += eval(classname).objects.filter(**{ attr_name: filename }).all() # the image can also be used by one of the text fields for classname, attr_names in settings.TEXT_FIELDS: for attr_name in attr_names: used_by += eval(classname).objects.filter( **{ attr_name + '__icontains': filename }).all() return used_by site = FileBrowserSite(name='filebrowser', storage=storage) # Default actions site.add_action(flip_horizontal) site.add_action(flip_vertical) site.add_action(rotate_90_clockwise) site.add_action(rotate_90_counterclockwise) site.add_action(rotate_180)
from django.conf.urls import include, url from filebrowser.sites import site from django.contrib import admin from django.core.files.storage import DefaultStorage from filebrowser.sites import FileBrowserSite from views import MyIndexView from opress.views import * # Default FileBrowser site site = FileBrowserSite(name='[:SAMPLE_PROJECT:]', storage=DefaultStorage()) site.directory = "uploads/" urlpatterns = [ url(r'^grappelli/', include('grappelli.urls')), url(r'^photologue/', include('photologue.urls', namespace='photologue')), url(r'^tinymce/', include('tinymce.urls')), url(r'^admin/filebrowser/', include(site.urls)), url(r'^$', MyIndexView.as_view(), name='index'), url(r'^', include('opress.urls', namespace='opress')), url(r'^admin/', include(admin.site.urls)), ] handler404 = 'opress.views.error404'
# As of version 3.4, all urls moved to FileBrowserSite class in filebrowser.sites # This file will be removed with version 3.6 import os from filebrowser.sites import FileBrowserSite from filebrowser.storage import S3BotoStorageMixin from shopcraft.s3utils import MediaRootS3BotoStorage from django.core.files.storage import default_storage storage = default_storage if 'ON_HEROKU' in os.environ: s3storage = MediaRootS3BotoStorage() if S3BotoStorageMixin not in s3storage.__class__.__bases__: s3storage.__class__.__bases__ += (S3BotoStorageMixin,) storage = s3storage site = FileBrowserSite(name='filebrowser', storage=default_storage) urlpatterns = site.get_urls()
from django.contrib import admin from django.conf import settings from django.core.files.storage import DefaultStorage from filebrowser.sites import FileBrowserSite filebrowser_site = FileBrowserSite(name='filebrowser', storage=DefaultStorage()) filebrowser_site.directory = "documents/" admin.autodiscover() admin.site.site_title = settings.ADMIN_SITE_TITLE or 'My site admin' admin.site.site_header = settings.ADMIN_SITE_HEADER or 'My administration' admin.site.index_title = settings.ADMIN_INDEX_TITLE or 'Site administration'