Browse Source

Merge pull request #1123 from rafalp/remove-misago-start

Remove misago-start.py
Rafał Pitoń 6 years ago
parent
commit
de986499e3
52 changed files with 177 additions and 384 deletions
  1. 1 24
      .gitignore
  2. 0 1
      Dockerfile
  3. 13 2
      README.rst
  4. 18 73
      dev
  5. 0 0
      devproject/__init__.py
  6. BIN
      devproject/avatargallery/Colors/0.jpg
  7. BIN
      devproject/avatargallery/Colors/1.jpg
  8. BIN
      devproject/avatargallery/Grays/0.jpg
  9. BIN
      devproject/avatargallery/Grays/1.jpg
  10. 2 0
      devproject/media/.gitignore
  11. 36 28
      devproject/settings.py
  12. 71 0
      devproject/test_settings.py
  13. 1 1
      devproject/urls.py
  14. 2 0
      devproject/userdata/.gitignore
  15. 3 3
      devproject/wsgi.py
  16. 1 1
      manage.py
  17. 0 69
      misago/bin/misago-start-devproject.py
  18. 0 6
      misago/bin/misago-start.py
  19. BIN
      misago/project_template/avatargallery/Nature/0.jpg
  20. BIN
      misago/project_template/avatargallery/Nature/1.jpg
  21. BIN
      misago/project_template/avatargallery/Nature/10.jpg
  22. BIN
      misago/project_template/avatargallery/Nature/11.jpg
  23. BIN
      misago/project_template/avatargallery/Nature/12.jpg
  24. BIN
      misago/project_template/avatargallery/Nature/13.jpg
  25. BIN
      misago/project_template/avatargallery/Nature/14.jpg
  26. BIN
      misago/project_template/avatargallery/Nature/15.jpg
  27. BIN
      misago/project_template/avatargallery/Nature/16.jpg
  28. BIN
      misago/project_template/avatargallery/Nature/17.jpg
  29. BIN
      misago/project_template/avatargallery/Nature/2.jpg
  30. BIN
      misago/project_template/avatargallery/Nature/3.jpg
  31. BIN
      misago/project_template/avatargallery/Nature/4.jpg
  32. BIN
      misago/project_template/avatargallery/Nature/5.jpg
  33. BIN
      misago/project_template/avatargallery/Nature/6.jpg
  34. BIN
      misago/project_template/avatargallery/Nature/7.jpg
  35. BIN
      misago/project_template/avatargallery/Nature/8.jpg
  36. BIN
      misago/project_template/avatargallery/Nature/9.jpg
  37. 0 5
      misago/project_template/avatargallery/README.txt
  38. BIN
      misago/project_template/avatargallery/Space/0.jpg
  39. BIN
      misago/project_template/avatargallery/Space/1.jpg
  40. BIN
      misago/project_template/avatargallery/Space/2.jpg
  41. BIN
      misago/project_template/avatargallery/Space/3.jpg
  42. BIN
      misago/project_template/avatargallery/Space/4.jpg
  43. 0 16
      misago/project_template/cron.txt
  44. 0 0
      misago/project_template/media/index.html
  45. 0 2
      misago/project_template/static/README.txt
  46. 0 0
      misago/project_template/static/index.html
  47. 0 1
      misago/project_template/theme/static/README.txt
  48. 0 1
      misago/project_template/theme/templates/README.txt
  49. 0 3
      misago/project_template/userdata/README.txt
  50. 6 6
      requirements.txt
  51. 23 136
      runtests.py
  52. 0 6
      setup.py

+ 1 - 24
.gitignore

@@ -20,7 +20,7 @@ var/
 *.egg
 *.egg
 node_modules/
 node_modules/
 
 
-# OS stuff
+# OS files
 .DS_Store
 .DS_Store
 thumbs.db
 thumbs.db
 
 
@@ -51,29 +51,6 @@ pylint.txt
 .idea/
 .idea/
 .vscode/
 .vscode/
 
 
-# Rope
-.ropeproject
-
 # Django stuff:
 # Django stuff:
 *.log
 *.log
 *.pot
 *.pot
-
-# GitBook Documentation
-_book/
-
-# Local development stuff
-dev/
-env/
-venv/
-misago-admin.py
-db.sqlite3
-
-# Local development files
-/avatargallery/
-/avatar_store/
-/devproject/
-/testproject/
-/media/
-/static/
-/userdata/
-/manage.py

+ 0 - 1
Dockerfile

@@ -5,7 +5,6 @@ FROM python:3.6
 
 
 ENV PYTHONUNBUFFERED 1
 ENV PYTHONUNBUFFERED 1
 ENV IN_MISAGO_DOCKER 1
 ENV IN_MISAGO_DOCKER 1
-ENV PATH "$PATH:/srv/misago"
 
 
 # Install dependencies in one single command/layer
 # Install dependencies in one single command/layer
 RUN apt-get update && apt-get install -y \
 RUN apt-get update && apt-get install -y \

+ 13 - 2
README.rst

@@ -88,14 +88,25 @@ Development
 
 
 Preferred way to run Misago development instances on your machine is with `Docker <https://www.docker.com/community-edition#/download>`_, which makes it easy to spin up arbitrary number of instances running different code with separate databases and dependencies besides each other.
 Preferred way to run Misago development instances on your machine is with `Docker <https://www.docker.com/community-edition#/download>`_, which makes it easy to spin up arbitrary number of instances running different code with separate databases and dependencies besides each other.
 
 
-To start, clone the repository and run ``./dev init`` command in your terminal. This will build necessary docker containers, install python dependencies, initialize the database and create development project for you. After command does its magic, you will be able to start development server using the ``docker-compose up`` command.
+To start, clone the repository and run ``./dev init`` command in your terminal. This will build necessary docker containers, install python dependencies and initialize the database. After command does its magic, you will be able to start development server using the ``docker-compose up`` command.
 
 
 After development server starts, visit the ``http://127.0.0.1:8000/`` in your browser to see your Misago installation.
 After development server starts, visit the ``http://127.0.0.1:8000/`` in your browser to see your Misago installation.
 
 
 Admin Control Panel is available under the ``http://127.0.0.1:8000/admincp/`` address. To log in to it use ``Admin`` username and ``password`` password.
 Admin Control Panel is available under the ``http://127.0.0.1:8000/admincp/`` address. To log in to it use ``Admin`` username and ``password`` password.
 
 
 The ``./dev`` utility implements other features besides the ``init``. Run it without any arguments to get the list of available actions.
 The ``./dev`` utility implements other features besides the ``init``. Run it without any arguments to get the list of available actions.
- 
+
+
+Running Misago in development without `dev`
+-------------------------------------------
+
+You may skip `./dev init` and setup dev instance manually, running those commands:
+
+1. `docker-compose build` - builds docker containers
+2. `docker-compose run --rm misago python manage.py migrate` - runs migrations
+3. `docker-compose run --rm misago python manage.py createsuperuser` - creates test user
+4. `docker-compose up` - starts dev server
+
 
 
 Frontend
 Frontend
 --------
 --------

+ 18 - 73
dev

@@ -7,19 +7,6 @@ RED='\033[0;31m'
 BOLD=$(tput bold)
 BOLD=$(tput bold)
 NORMAL=$(tput sgr0)
 NORMAL=$(tput sgr0)
 
 
-# Define dev paths
-# Those are paths to dirs and files created for dev project
-dev_paths=(
-    "./avatargallery"
-    "./devproject"
-    "./media"
-    "./static"
-    "./theme"
-    "./userdata"
-    "./cron.txt"
-    "./manage.py"
-)
-
 # Required ports
 # Required ports
 # Some tasks test for those ports before continuing
 # Some tasks test for those ports before continuing
 port_django=8000
 port_django=8000
@@ -75,11 +62,11 @@ intro() {
     echo
     echo
     echo "Development project:"
     echo "Development project:"
     echo
     echo
-    echo "    ${BOLD}init${NORMAL}              initialize new dev project for development, does nothing if project already exists."
+    echo "    ${BOLD}init${NORMAL}              initialize dev database for development."
     echo "    ${BOLD}afterinit${NORMAL}         repeat help message displayed after init command is complete."
     echo "    ${BOLD}afterinit${NORMAL}         repeat help message displayed after init command is complete."
-    echo "    ${BOLD}remove${NORMAL}            if dev project exists, remove its files and docker containers."
+    echo "    ${BOLD}clear${NORMAL}             clear media and userdata dirs and destroy docker containers."
     echo "    ${BOLD}rebuild${NORMAL}           rebuild docker containers."
     echo "    ${BOLD}rebuild${NORMAL}           rebuild docker containers."
-    echo "    ${BOLD}reset${NORMAL}             run remove followed by init."
+    echo "    ${BOLD}reset${NORMAL}             run clear followed by init."
     echo
     echo
     echo "    Both init and rebuild args can be followed with any number of extra args and options that should be appended to docker-compose build."
     echo "    Both init and rebuild args can be followed with any number of extra args and options that should be appended to docker-compose build."
     echo
     echo
@@ -115,16 +102,6 @@ invalid_argument() {
 
 
 # Initialize new dev project
 # Initialize new dev project
 init() {
 init() {
-    for dev_path in "${dev_paths[@]}"; do
-        if [ -e $dev_path ]; then
-            error "Dev project already exists, or was not deleted completely."
-            echo
-            echo "Please use \"remove\" option to remove any possible remaining files and try again."
-            echo
-            exit 1
-        fi
-    done
-
     for port in "${required_ports[@]}"; do
     for port in "${required_ports[@]}"; do
         nc "127.0.0.1" "$port" < /dev/null
         nc "127.0.0.1" "$port" < /dev/null
         if [[ $? = "0" ]]; then
         if [[ $? = "0" ]]; then
@@ -150,16 +127,6 @@ init() {
 init_in_docker() {
 init_in_docker() {
     require_in_docker
     require_in_docker
     wait_for_db
     wait_for_db
-    # initialize django project
-    python misago/bin/misago-start-devproject.py
-    # move items of interest up one level
-    mv devproject/devproject devproject_tmp
-    mv devproject/avatargallery ./avatargallery
-    mv devproject/media ./media
-    mv devproject/userdata ./userdata
-    mv devproject/manage.py ./manage.py
-    rm -rf devproject
-    mv devproject_tmp devproject
     # migrate the database
     # migrate the database
     python manage.py migrate
     python manage.py migrate
     # create superuser Admin with password "password"
     # create superuser Admin with password "password"
@@ -185,13 +152,6 @@ after_init_message() {
     echo "Username:    $username"
     echo "Username:    $username"
     echo "Password:    $password"
     echo "Password:    $password"
     echo
     echo
-    echo "Development project directories:"
-    echo
-    echo "devproject        configuration files for development instance."
-    echo "media             user uploaded files."
-    echo "userdata          working directory for user data exports."
-    echo "avatargallery     example avatar gallery."
-    echo
     echo "To connect to development database use following credentials:"
     echo "To connect to development database use following credentials:"
     echo
     echo
     echo "User:         misago"
     echo "User:         misago"
@@ -204,40 +164,26 @@ after_init_message() {
     echo
     echo
 }
 }
 
 
-# Remove existing dev project
-remove() {
-    echo -e "${RED}Warning:${NORMAL} You are going remove current development project."
+# Clear existing dev project
+clear() {
+    echo -e "${RED}Warning:${NORMAL} You are going to delete media files created during development and destroy docker containers."
     echo
     echo
 
 
-    will_delete_files=false
-    for dev_path in "${dev_paths[@]}"; do
-        if [ -e $dev_path ]; then
-            will_delete_files=true
-        fi
-    done
-    if [[ $will_delete_files = true ]]; then
-        echo "Following files and directories will be deleted:"
-        for dev_path in "${dev_paths[@]}"; do
-            if [ -e $dev_path ]; then
-                echo "  $dev_path"
-            fi
-        done
-        echo
-    fi
+    devproject_path="$(pwd)/devproject"
 
 
+    echo "Following files and directories will be deleted:"
+    find $devproject_path/media -mindepth 1 ! -name '.gitignore'
+    find $devproject_path/userdata -mindepth 1 ! -name '.gitignore'
+    echo
+        
     echo "Enter \"y\" to confirm:"
     echo "Enter \"y\" to confirm:"
 
 
     read confirmation
     read confirmation
     if [[ $confirmation = "y" ]]; then
     if [[ $confirmation = "y" ]]; then
-        for dev_path in "${dev_paths[@]}"; do
-            if [ -e $dev_path ]; then
-                echo "Removing $dev_path"
-                rm -rf $dev_path
-            fi
-        done
-
         docker-compose stop
         docker-compose stop
         docker-compose down --remove-orphans
         docker-compose down --remove-orphans
+        find $devproject_path/media -mindepth 1 ! -name '.gitignore' -delete
+        find $devproject_path/userdata -mindepth 1 ! -name '.gitignore' -delete
     else
     else
         echo "Operation canceled."
         echo "Operation canceled."
     fi
     fi
@@ -251,8 +197,7 @@ rebuild() {
 
 
 # Run tests suite
 # Run tests suite
 test() {
 test() {
-    docker-compose run --rm misago runtests.py $1
-    docker-compose stop
+    docker-compose run --rm misago python runtests.py $1
 }
 }
 
 
 # Make messages
 # Make messages
@@ -331,10 +276,10 @@ if [[ $1 ]]; then
         init_in_docker
         init_in_docker
     elif [[ $1 = "afterinit" ]]; then
     elif [[ $1 = "afterinit" ]]; then
         after_init_message
         after_init_message
-    elif [[ $1 = "remove" ]]; then
-        remove
+    elif [[ $1 = "clear" ]]; then
+        clear
     elif [[ $1 = "reset" ]]; then
     elif [[ $1 = "reset" ]]; then
-        remove
+        clear
         init $@
         init $@
     elif [[ $1 = "rebuild" ]]; then
     elif [[ $1 = "rebuild" ]]; then
         rebuild $@
         rebuild $@

+ 0 - 0
misago/project_template/project_name/__init__.py → devproject/__init__.py


BIN
devproject/avatargallery/Colors/0.jpg


BIN
devproject/avatargallery/Colors/1.jpg


BIN
devproject/avatargallery/Grays/0.jpg


BIN
devproject/avatargallery/Grays/1.jpg


+ 2 - 0
devproject/media/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 36 - 28
misago/project_template/project_name/settings.py → devproject/settings.py

@@ -1,20 +1,20 @@
 """
 """
-Django settings for {{ project_name }} project.
+Django settings for dev project.
 
 
-Generated by 'django-admin startproject' using Django {{ django_version }}.
+Generated by 'django-admin startproject' using Django 1.11.15.
 
 
 For more information on this file, see
 For more information on this file, see
-https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
+https://docs.djangoproject.com/en/1.11/topics/settings/
 
 
 For the full list of settings and their values, see
 For the full list of settings and their values, see
-https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
+https://docs.djangoproject.com/en/1.11/ref/settings/
 """
 """
 
 
 import os
 import os
 
 
 
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+BASE_DIR = os.path.dirname(os.path.abspath(__file__))
 
 
 
 
 # Define placeholder gettext function
 # Define placeholder gettext function
@@ -24,10 +24,10 @@ _ = lambda s: s
 
 
 
 
 # Quick-start development settings - unsuitable for production
 # Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
 
 
 # SECURITY WARNING: keep the secret key used in production secret!
 # SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = '{{ secret_key }}'
+SECRET_KEY = '1znyfpwp*_#!r0#l248lht*6)_0b+504n*2-8cxf(2u)fhi0f^'
 
 
 # SECURITY WARNING: don't run with debug turned on in production!
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
 DEBUG = True
@@ -40,23 +40,23 @@ ALLOWED_HOSTS = []
 
 
 
 
 # Database
 # Database
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#databases
+# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
 
 
 DATABASES = {
 DATABASES = {
     'default': {
     'default': {
         # Misago requires PostgreSQL to run
         # Misago requires PostgreSQL to run
         'ENGINE': 'django.db.backends.postgresql',
         'ENGINE': 'django.db.backends.postgresql',
-        'NAME': '',
-        'USER': '',
-        'PASSWORD': '',
-        'HOST': 'localhost',
+        'NAME': os.environ.get('POSTGRES_DB'),
+        'USER': os.environ.get('POSTGRES_USER'),
+        'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
+        'HOST': os.environ.get('POSTGRES_HOST'),
         'PORT': 5432,
         'PORT': 5432,
     }
     }
 }
 }
 
 
 
 
 # Caching
 # Caching
-# https://docs.djangoproject.com/en/{{ docs_version }}/topics/cache/#setting-up-the-cache
+# https://docs.djangoproject.com/en/1.11/topics/cache/#setting-up-the-cache
 
 
 CACHES = {
 CACHES = {
     'default': {
     'default': {
@@ -67,7 +67,7 @@ CACHES = {
 
 
 
 
 # Password validation
 # Password validation
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
 
 
 AUTH_PASSWORD_VALIDATORS = [
 AUTH_PASSWORD_VALIDATORS = [
     {
     {
@@ -92,7 +92,7 @@ AUTH_PASSWORD_VALIDATORS = [
 
 
 
 
 # Internationalization
 # Internationalization
-# https://docs.djangoproject.com/en/{{ docs_version }}/topics/i18n/
+# https://docs.djangoproject.com/en/1.11/topics/i18n/
 
 
 LANGUAGE_CODE = 'en-us'
 LANGUAGE_CODE = 'en-us'
 
 
@@ -106,25 +106,25 @@ USE_TZ = True
 
 
 
 
 # Static files (CSS, JavaScript, Images)
 # Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
+# https://docs.djangoproject.com/en/1.11/howto/static-files/
 
 
 STATIC_URL = '/static/'
 STATIC_URL = '/static/'
 
 
 
 
 # User uploads (Avatars, Attachments, files uploaded in other Django apps, ect.)
 # User uploads (Avatars, Attachments, files uploaded in other Django apps, ect.)
-# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
+# https://docs.djangoproject.com/en/1.11/howto/static-files/
 
 
 MEDIA_URL = '/media/'
 MEDIA_URL = '/media/'
 
 
 
 
 # The absolute path to the directory where collectstatic will collect static files for deployment.
 # The absolute path to the directory where collectstatic will collect static files for deployment.
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#static-root
+# https://docs.djangoproject.com/en/1.11/ref/settings/#static-root
 
 
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
 
 
 
 
 # Absolute filesystem path to the directory that will hold user-uploaded files.
 # Absolute filesystem path to the directory that will hold user-uploaded files.
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#media-root
+# https://docs.djangoproject.com/en/1.11/ref/settings/#media-root
 
 
 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 
 
@@ -133,13 +133,11 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 # is enabled, e.g. if you use the collectstatic or findstatic management command or use the static file serving view.
 # is enabled, e.g. if you use the collectstatic or findstatic management command or use the static file serving view.
 # https://docs.djangoproject.com/en/1.10/ref/settings/#staticfiles-dirs
 # https://docs.djangoproject.com/en/1.10/ref/settings/#staticfiles-dirs
 
 
-STATICFILES_DIRS = [
-    os.path.join(BASE_DIR, 'theme', 'static'),
-]
+STATICFILES_DIRS = []
 
 
 
 
 # Email configuration
 # Email configuration
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#email-backend
+# https://docs.djangoproject.com/en/1.11/ref/settings/#email-backend
 
 
 EMAIL_HOST = 'localhost'
 EMAIL_HOST = 'localhost'
 EMAIL_PORT = 25
 EMAIL_PORT = 25
@@ -234,7 +232,7 @@ MIDDLEWARE = [
     'misago.core.middleware.threadstore.ThreadStoreMiddleware',
     'misago.core.middleware.threadstore.ThreadStoreMiddleware',
 ]
 ]
 
 
-ROOT_URLCONF = '{{ project_name }}.urls'
+ROOT_URLCONF = 'devproject.urls'
 
 
 SOCIAL_AUTH_PIPELINE = (
 SOCIAL_AUTH_PIPELINE = (
     # Steps required by social pipeline to work - don't delete those!
     # Steps required by social pipeline to work - don't delete those!
@@ -273,9 +271,7 @@ SOCIAL_AUTH_POSTGRES_JSONFIELD = True
 TEMPLATES = [
 TEMPLATES = [
     {
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [
-            os.path.join(BASE_DIR, 'theme', 'templates'),
-        ],
+        'DIRS': [],
         'APP_DIRS': True,
         'APP_DIRS': True,
         'OPTIONS': {
         'OPTIONS': {
             'context_processors': [
             'context_processors': [
@@ -310,7 +306,7 @@ TEMPLATES = [
     },
     },
 ]
 ]
 
 
-WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
+WSGI_APPLICATION = 'devproject.wsgi.application'
 
 
 
 
 # Django Crispy Forms
 # Django Crispy Forms
@@ -444,3 +440,15 @@ MISAGO_PROFILE_FIELDS = [
         ],
         ],
     },
     },
 ]
 ]
+
+
+# Set dev instance to send e-mails to console
+
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+
+# Display debug toolbar if IN_MISAGO_DOCKER enviroment var is set to "1"
+
+DEBUG_TOOLBAR_CONFIG = {
+    'SHOW_TOOLBAR_CALLBACK': 'misago.conf.debugtoolbar.enable_debug_toolbar'
+}

+ 71 - 0
devproject/test_settings.py

@@ -0,0 +1,71 @@
+import os
+
+from .settings import *  # pylint: disable-all
+
+# Use test DB
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.postgresql_psycopg2',
+        'NAME': os.environ.get('POSTGRES_TEST_DB'),
+        'USER': os.environ.get('POSTGRES_USER'),
+        'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
+        'HOST': os.environ.get('POSTGRES_HOST'),
+        'PORT': 5432,
+    }
+}
+
+# Use in-memory cache
+CACHES = {
+    'default': {
+        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+        'LOCATION': 'uniqu3-sn0wf14k3'
+    }
+}
+
+# Disable Debug Toolbar
+DEBUG_TOOLBAR_CONFIG = {}
+INTERNAL_IPS = []
+
+# Disable account validation via Stop Forum Spam
+MISAGO_NEW_REGISTRATIONS_VALIDATORS = (
+    'misago.users.validators.validate_gmail_email',
+)
+
+# Store mails in memory
+EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
+
+# Use MD5 password hashing to speed up test suite
+PASSWORD_HASHERS = (
+    'django.contrib.auth.hashers.MD5PasswordHasher',
+)
+
+# Default misago address to test address
+MISAGO_ADDRESS = 'http://testserver/'
+
+# Use english search config
+MISAGO_SEARCH_CONFIG = 'english'
+
+# Register test post validator
+MISAGO_POST_VALIDATORS = [
+    'misago.core.testproject.validators.test_post_validator',
+]
+
+# Register test post search filter
+MISAGO_POST_SEARCH_FILTERS = [
+    'misago.core.testproject.searchfilters.test_filter',
+]
+
+# Additional overrides for Travis-CI
+if os.environ.get('TRAVIS'):
+    DATABASES = {
+        'default': {
+            'ENGINE': 'django.db.backends.postgresql_psycopg2',
+            'NAME': 'travis_ci_test',
+            'USER': 'postgres',
+            'PASSWORD': '',
+            'HOST': '127.0.0.1',
+            'PORT': '',
+        }
+    }
+
+    TEST_NAME = 'travis_ci_test'

+ 1 - 1
misago/project_template/project_name/urls.py → devproject/urls.py

@@ -1,4 +1,4 @@
-"""{{ project_name }} URL Configuration
+"""devproject URL Configuration
 
 
 The `urlpatterns` list routes URLs to views. For more information please see:
 The `urlpatterns` list routes URLs to views. For more information please see:
     https://docs.djangoproject.com/en/1.10/topics/http/urls/
     https://docs.djangoproject.com/en/1.10/topics/http/urls/

+ 2 - 0
devproject/userdata/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 3 - 3
misago/project_template/project_name/wsgi.py → devproject/wsgi.py

@@ -1,10 +1,10 @@
 """
 """
-WSGI config for {{ project_name }} project.
+WSGI config for devproject project.
 
 
 It exposes the WSGI callable as a module-level variable named ``application``.
 It exposes the WSGI callable as a module-level variable named ``application``.
 
 
 For more information on this file, see
 For more information on this file, see
-https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/
+https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
 """
 """
 
 
 import os
 import os
@@ -12,6 +12,6 @@ import os
 from django.core.wsgi import get_wsgi_application
 from django.core.wsgi import get_wsgi_application
 
 
 
 
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "devproject.settings")
 
 
 application = get_wsgi_application()
 application = get_wsgi_application()

+ 1 - 1
misago/project_template/manage.py → manage.py

@@ -4,7 +4,7 @@ import sys
 
 
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
-    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "devproject.settings")
     try:
     try:
         from django.core.management import execute_from_command_line
         from django.core.management import execute_from_command_line
     except ImportError:
     except ImportError:

+ 0 - 69
misago/bin/misago-start-devproject.py

@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-# pylint: disable=E0401
-"""
-Creates a dev project for local development
-"""
-
-import os
-import sys
-
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-PROJECT_NAME = 'devproject'
-
-
-def main():
-    settings_file = os.path.join(BASE_DIR, PROJECT_NAME, PROJECT_NAME, 'settings.py')
-
-    # Avoid recreating if already present
-    if os.path.exists(settings_file):
-        return
-
-    from misago.core import setup
-
-    setup.start_misago_project()
-    fill_in_settings(settings_file)
-
-
-def fill_in_settings(f):
-    with open(f, 'r') as fd:
-        s = fd.read()
-
-        # Read PostgreSQL's config from env variables
-        s = s.replace("'NAME': '',", "'NAME': os.environ.get('POSTGRES_DB'),")
-        s = s.replace("'USER': '',", "'USER': os.environ.get('POSTGRES_USER'),")
-        s = s.replace("'PASSWORD': '',", "'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),")
-        s = s.replace("'HOST': 'localhost',", "'HOST': os.environ.get('POSTGRES_HOST'),")
-
-        # Specify console backend for email
-        s += "\n"
-        s += "\n# Set dev instance to send e-mails to console"
-        s += "\n"
-        s += "\nEMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'"
-        s += "\n"
-
-        # Tie Debug Toolbar visibility to env variable
-        s += "\n"
-        s += "\n# Display debug toolbar if IN_MISAGO_DOCKER enviroment var is set to \"1\""
-        s += "\n"
-        s += "\nDEBUG_TOOLBAR_CONFIG = {"
-        s += "\n    'SHOW_TOOLBAR_CALLBACK': 'misago.conf.debugtoolbar.enable_debug_toolbar'"
-        s += "\n}"
-        s += "\n"
-
-        # Empty the contents of STATICFILES_DIRS (STATICFILES_DIRS = [])
-        pos = s.find('STATICFILES_DIRS')
-        s = s[:s.find('[', pos) + 1] + s[s.find(']', pos):]
-
-        # Remove theme dir from template dirs
-        pos = s.find("'DIRS': [")
-        s = s[:s.find('[', pos) + 1] + s[s.find(']', pos):]
-
-    with open(f, 'w') as fd:
-        fd.write(s)
-
-
-if __name__ == '__main__':
-    sys.argv.append(PROJECT_NAME)
-    sys.path.append(BASE_DIR)
-    main()

+ 0 - 6
misago/bin/misago-start.py

@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-from misago.core.setup import start_misago_project
-
-
-if __name__ == "__main__":
-    start_misago_project()

BIN
misago/project_template/avatargallery/Nature/0.jpg


BIN
misago/project_template/avatargallery/Nature/1.jpg


BIN
misago/project_template/avatargallery/Nature/10.jpg


BIN
misago/project_template/avatargallery/Nature/11.jpg


BIN
misago/project_template/avatargallery/Nature/12.jpg


BIN
misago/project_template/avatargallery/Nature/13.jpg


BIN
misago/project_template/avatargallery/Nature/14.jpg


BIN
misago/project_template/avatargallery/Nature/15.jpg


BIN
misago/project_template/avatargallery/Nature/16.jpg


BIN
misago/project_template/avatargallery/Nature/17.jpg


BIN
misago/project_template/avatargallery/Nature/2.jpg


BIN
misago/project_template/avatargallery/Nature/3.jpg


BIN
misago/project_template/avatargallery/Nature/4.jpg


BIN
misago/project_template/avatargallery/Nature/5.jpg


BIN
misago/project_template/avatargallery/Nature/6.jpg


BIN
misago/project_template/avatargallery/Nature/7.jpg


BIN
misago/project_template/avatargallery/Nature/8.jpg


BIN
misago/project_template/avatargallery/Nature/9.jpg


+ 0 - 5
misago/project_template/avatargallery/README.txt

@@ -1,5 +0,0 @@
-This directory contains your site's avatar gallery. It has been already prepopulated with some two example galleries: "Nature" and "Space". You can load those to your forum using "loadavatargallery".
-
-Feel free to remove existing galleries or add your own.
-
-If you create gallery named "__default__" and set avatar gallery as default user avatar, Misago will select new users avatars from it while keeping this gallery hidden from existing users.

BIN
misago/project_template/avatargallery/Space/0.jpg


BIN
misago/project_template/avatargallery/Space/1.jpg


BIN
misago/project_template/avatargallery/Space/2.jpg


BIN
misago/project_template/avatargallery/Space/3.jpg


BIN
misago/project_template/avatargallery/Space/4.jpg


+ 0 - 16
misago/project_template/cron.txt

@@ -1,16 +0,0 @@
-# this is example crontab configuration
-# you'll likely need to change it to use
-# valid python version or paths to manage.py
-
-0 1 * * * python manage.py deletemarkedusers
-5 1 * * * python manage.py prunecategories
-10 1 * * * python manage.py buildactivepostersranking
-15 1 * * * python manage.py clearattachments
-20 1 * * * python manage.py clearreadtracker
-25 1 * * * python manage.py clearsessions
-30 1 * * * python manage.py clearsocial
-35 1 * * * python manage.py invalidatebans
-40 1 * * * python manage.py removeoldips
-45 1 * * * python manage.py deleteinactiveusers
-50 1 * * * python manage.py expireuserdatadownloads
-0 7 * * * python manage.py prepareuserdatadownloads

+ 0 - 0
misago/project_template/media/index.html


+ 0 - 2
misago/project_template/static/README.txt

@@ -1,2 +0,0 @@
-This directory is used to gather publicly available assets like images, icons, css filers et all.
-Don't put any files here yourself, as they may be deleted by "collectstatic" command. Use "theme/static" directory instead.

+ 0 - 0
misago/project_template/static/index.html


+ 0 - 1
misago/project_template/theme/static/README.txt

@@ -1 +0,0 @@
-You can use this directory to replace default assets with custom ones or add new ones to your site. Remember to use collectstatic command with "-c" argument to make your changes visible.

+ 0 - 1
misago/project_template/theme/templates/README.txt

@@ -1 +0,0 @@
-You can use this directory to replace default templates with custom ones as well as add new ones to your theme.

+ 0 - 3
misago/project_template/userdata/README.txt

@@ -1,3 +0,0 @@
-This directory is used by Misago to prepare user data downloads.
-
-Make sure it's not accessible from internet.

+ 6 - 6
requirements.txt

@@ -6,13 +6,13 @@
 #
 #
 beautifulsoup4==4.6.3
 beautifulsoup4==4.6.3
 bleach==2.1.4
 bleach==2.1.4
-certifi==2018.8.24        # via requests
+certifi==2018.10.15       # via requests
 chardet==3.0.4            # via requests
 chardet==3.0.4            # via requests
 django-crispy-forms==1.6.1
 django-crispy-forms==1.6.1
 django-debug-toolbar==1.8
 django-debug-toolbar==1.8
 django-htmlmin==0.10.0
 django-htmlmin==0.10.0
 django-mptt==0.8.7
 django-mptt==0.8.7
-django==1.11.15
+django==1.11.16
 djangorestframework==3.6.4
 djangorestframework==3.6.4
 faker==0.8.18
 faker==0.8.18
 html5lib==0.999999999
 html5lib==0.999999999
@@ -21,12 +21,12 @@ ipaddress==1.0.22         # via faker
 markdown==2.6.11
 markdown==2.6.11
 misago-social-auth-app-django==2.1.0
 misago-social-auth-app-django==2.1.0
 oauthlib==2.1.0           # via requests-oauthlib, social-auth-core
 oauthlib==2.1.0           # via requests-oauthlib, social-auth-core
-olefile==0.45.1           # via pillow
+olefile==0.46             # via pillow
 pillow==4.1.1
 pillow==4.1.1
 psycopg2-binary==2.7.5
 psycopg2-binary==2.7.5
 pyjwt==1.6.4              # via social-auth-core
 pyjwt==1.6.4              # via social-auth-core
-python-dateutil==2.7.3    # via faker
-pytz==2018.5
+python-dateutil==2.7.5    # via faker
+pytz==2018.7
 requests-oauthlib==1.0.0  # via social-auth-core
 requests-oauthlib==1.0.0  # via social-auth-core
 requests==2.20.0
 requests==2.20.0
 six==1.11.0               # via bleach, faker, html5lib, misago-social-auth-app-django, python-dateutil, social-auth-core
 six==1.11.0               # via bleach, faker, html5lib, misago-social-auth-app-django, python-dateutil, social-auth-core
@@ -34,5 +34,5 @@ social-auth-core==1.7.0   # via misago-social-auth-app-django
 sqlparse==0.2.4           # via django-debug-toolbar
 sqlparse==0.2.4           # via django-debug-toolbar
 text-unidecode==1.2       # via faker
 text-unidecode==1.2       # via faker
 unidecode==0.4.21
 unidecode==0.4.21
-urllib3==1.23             # via requests
+urllib3==1.24.1           # via requests
 webencodings==0.5.1       # via html5lib
 webencodings==0.5.1       # via html5lib

+ 23 - 136
runtests.py

@@ -1,148 +1,35 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 import os
 import os
-import pwd
-import shutil
 import sys
 import sys
 
 
-from django import setup
-
-
-TEST_RUNNER_PATH = os.path.dirname(os.path.abspath(__file__))
-
-sys.path.append(os.path.dirname(os.path.abspath(__file__)))
-
 
 
 def runtests():
 def runtests():
-    args, kwargs = parse_args()
-    setup_testproject()
-    run_django(*args, **kwargs)
-
-
-def parse_args():
-    args = []
-    kwargs = {
-        'verbosity': 1,
-        'noinput': True,
-    }
-
-    sys_argv = sys.argv[1:]
-    if sys_argv and sys_argv[0] == 'test':
-        sys_argv = sys_argv[1:]
-
-    for arg in sys_argv:
-        if arg == '--verbose':
-            kwargs['verbosity'] = 2
-        else:
-            args.append(arg)
-
-    return args, kwargs
-
-
-def setup_testproject():
-    project_template_path = os.path.join(TEST_RUNNER_PATH, 'misago/project_template')
-
-    test_project_path = os.path.join(TEST_RUNNER_PATH, "testproject")
-    if os.path.exists(test_project_path):
-        shutil.rmtree(test_project_path)
-
-    shutil.copytree(project_template_path, test_project_path)
-
-    module_init_path = os.path.join(test_project_path, '__init__.py')
-    with open(module_init_path, "w") as py_file:
-        py_file.write('')
-
-    settings_path = os.path.join(
-        test_project_path, 'project_name', 'settings.py')
-
-    with open(settings_path, "r") as py_file:
-        settings_file = py_file.read()
-
-        # Do some configuration magic
-        settings_file = settings_file.replace('{{ project_name }}', 'testproject.project_name')
-        settings_file = settings_file.replace('{{ secret_key }}', 't3stpr0j3ct')
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "devproject.test_settings")
+    try:
+        from django import setup
+        from django.core.management import call_command
+    except ImportError:
+        # The above import may fail for some other reason. Ensure that the
+        # issue is really that Django is missing to avoid masking other
+        # exceptions on Python 2.
+        try:
+            import django
+        except ImportError:
+            raise ImportError(
+                "Couldn't import Django. Are you sure it's installed and "
+                "available on your PYTHONPATH environment variable? Did you "
+                "forget to activate a virtual environment?"
+            )
+        raise
 
 
-        settings_file += """
-# disable account validation via Stop Forum Spam
-MISAGO_NEW_REGISTRATIONS_VALIDATORS = (
-    'misago.users.validators.validate_gmail_email',
-)
-
-# store mails in memory
-EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
-
-# use in-memory cache
-CACHES = {
-    'default': {
-        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
-        'LOCATION': 'uniqu3-sn0wf14k3'
-    }
-}
-
-# Use MD5 password hashing to speed up test suite
-PASSWORD_HASHERS = (
-    'django.contrib.auth.hashers.MD5PasswordHasher',
-)
-
-# Default misago address to test address
-MISAGO_ADDRESS = 'http://testserver/'
-
-# Use english search config
-MISAGO_SEARCH_CONFIG = 'english'
-
-
-# Register test post validator
-MISAGO_POST_VALIDATORS = [
-    'misago.core.testproject.validators.test_post_validator',
-]
-
-
-# Register test post search filter
-MISAGO_POST_SEARCH_FILTERS = [
-    'misago.core.testproject.searchfilters.test_filter',
-]
-"""
-
-    if os.environ.get('TRAVIS'):
-        settings_file += """
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.postgresql_psycopg2',
-        'NAME': 'travis_ci_test',
-        'USER': 'postgres',
-        'PASSWORD': '',
-        'HOST': '127.0.0.1',
-        'PORT': '',
-    }
-}
-
-TEST_NAME = 'travis_ci_test'
-"""
-    else:
-        settings_file += """
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.postgresql_psycopg2',
-        'NAME': os.environ['POSTGRES_TEST_DB'],
-        'USER': os.environ['POSTGRES_USER'],
-        'PASSWORD': os.environ['POSTGRES_PASSWORD'],
-        'HOST': os.environ['POSTGRES_HOST'],
-        'PORT': 5432,
-    }
-}
-"""
-
-    with open(settings_path, "w") as py_file:
-        py_file.write(settings_file)
-
-    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.project_name.settings")
-
-
-def run_django(*args, **kwargs):
     setup()
     setup()
 
 
-    from django.core.management import call_command
-    sys.exit(call_command('test', *args, **kwargs))
+    modules = sys.argv[1:]
+    if "test" in modules:
+        modules.remove("test")
+
+    exit_code = call_command("test", *modules, verbosity=1, noinput=True)
+    sys.exit(exit_code)
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':

+ 0 - 6
setup.py

@@ -38,12 +38,6 @@ setup(
     install_requires=REQUIREMENTS,
     install_requires=REQUIREMENTS,
     packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
     packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
     include_package_data=True,
     include_package_data=True,
-    scripts=[
-        'misago/bin/misago-start.py',
-    ],
-    entry_points={'console_scripts': [
-        'misago-start = misago.core.setup:start_misago_project',
-    ]},
     test_suite="runtests.runtests",
     test_suite="runtests.runtests",
     classifiers=[
     classifiers=[
         'Development Status :: 4 - Beta',
         'Development Status :: 4 - Beta',