A estrutura de diretórios fica assim:
app_name/
|
`- __init__.py
|
`- admin.py
|
`- fixtures/
|
`- models.py
|
`- templates/
|
`- templatetags/
| |
| `- __init__.py
|
`- tests/
| |
| `- browser_tests.py
| |
| `- model_tests.py
| |
| `- nav_tests.py
|
`- urls.py
|
`- views.py
Segue o código (também disponível em [1]):
[1] http://pastebin.com/f1a862c33
res=$(CocoaDialog inputbox --title "Create Application" --informative-text \
"Application name:" --button1 "Ok" \
--button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
app_name=$(tail -n1 <<<"$res")
if [ -f "$TM_PROJECT_DIRECTORY/manage.py" ]; then
MANAGE="python manage.py"
else
MANAGE="django-admin.py"
fi
cd $TM_PROJECT_DIRECTORY
$MANAGE startapp $app_name
mkdir $app_name/templatetags $app_name/templates $app_name/tests \
$app_name/fixtures $app_name/media
touch $app_name/urls.py $app_name/admin.py $app_name/templatetags/__init__.py \
$app_name/tests/__init__.py
cat > $app_name/urls.py <<EOF
#insert your custom urls here.
from django.conf.urls.defaults import *
urlpatterns = patterns('',
)
EOF
cat > $app_name/admin.py <<EOF
from django.contrib.admin import site
from ${app_name}.models import *
EOF
cd $app_name/tests
for testtype in model browser nav; do
touch ${testtype}_tests.py
cat > ${testtype}_tests.py <<EOF
#${testtype} tests for ${app_name}
from django.test import TestCase
EOF
done
cd -
CocoaDialog ok-msgbox --title "Application Created." \
--informative-text "Application $TM_PROJECT_DIRECTORY/$app_name created." \
--button1 "Ok" --float
rescan_project
Nenhum comentário:
Postar um comentário