forked from smacker/django-filebrowser-no-grappelli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual_test_1.sh
executable file
·99 lines (76 loc) · 2.24 KB
/
manual_test_1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -e
# Setup project for Django <2.0
VIRTUALENV_DIR="envs"
PROJECTS_DIR="projects"
BASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
SED=sed
if [[ "$OSTYPE" == "darwin"* ]]; then
SED=gsed
fi
echo "prepare projects for manual testing"
source "$VIRTUALENV_DIR/$1/bin/activate"
PROJECT_PATH="$PROJECTS_DIR/fb-dj$1"
rm -rf $PROJECT_PATH
mkdir -p $PROJECT_PATH
django-admin startproject fb $PROJECT_PATH
ln -s "$BASEDIR/filebrowser" "$PROJECT_PATH/filebrowser"
echo "
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'filebrowser',
#'dummy',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'test.db'),
}
}
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
" >> "$PROJECT_PATH/fb/settings.py"
echo "
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url
from filebrowser.sites import site
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^admin/filebrowser/', include(site.urls)),
url(r'^admin/', include(admin.site.urls)),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
" > "$PROJECT_PATH/fb/urls.py"
(
cd $PROJECT_PATH
mkdir -p media/uploads/
mkdir -p media/_versions/
python manage.py test
python manage.py startapp dummy
echo "
from django.db import models
from filebrowser.fields import FileBrowseField, FileBrowseUploadField
class DemoItem(models.Model):
title = models.CharField('Title', max_length=210)
attach = FileBrowseField('Attach', max_length=200)
upload = FileBrowseUploadField('Attach', max_length=200)
" > dummy/models.py
echo "
from django.contrib import admin
from dummy.models import DemoItem
class DemoAdmin(admin.ModelAdmin):
pass
admin.site.register(DemoItem, DemoAdmin)
" > dummy/admin.py
$SED -i "s/#'dummy/'dummy/" fb/settings.py
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser --noinput --username admin --email admin@sample.com
)