Skip to content

Installation

Mike Seibel edited this page Aug 21, 2018 · 21 revisions

Build Your Development Environment:

Prerequisites: A Python installation (2.7 or greater), pip or easy_install, git

Step-by-step:

If you don't have it already, install virtualenv: $ pip install virtualenv If you don't have pip, you may be able to: $ easy_install virtualenv

  1. Checkout the master branch of the project repository into your service-endorsement directory:

    $ git clone [email protected]:uw-it-aca/service-endorsement.git ./service-endorsement OR git clone https://github.com/uw-it-aca/service-endorsement.git ./service-endorsement

  2. From within the new service-endorsement directory, switch to develop branch

    $ git checkout develop

  3. Make your service-endorsement directory into a virtualenv:

    $ virtualenv service-endorsement

  4. Activate your virtualenv:

    $ cd service-endorsement

    $ source bin/activate

  5. Install required Python packages with pip:

    $ pip install -r requirements.txt

  6. Create a django project in service-endorsement directory:

    $ django-admin.py startproject project .

    That '.' at the end is important!

    Make manage.py runable:

    $ chmod 755 manage.py

  7. Modify project/settings.py by adding the following:
    Add to your INSTALLED_APPS list

        'compressor',
        'templatetag_handlebars',
        'endorsement',
        'userservice',
        'authz_group',
        'uw_saml',
        'django_client_logger',
        'supporttools'

Add the variable

        DEFAULT_INDEX_TABLESPACE = ''

Change MIDDLEWARE to MIDDLEWARE_CLASSES, and add to the end of the list:

        'django.contrib.auth.middleware.PersistentRemoteUserMiddleware',
        'django_mobileesp.middleware.UserAgentDetectionMiddleware',
        'userservice.user.UserServiceMiddleware',

In the TEMPLATES setting add to the'OPTIONS' list:

        'supporttools.context_processors.supportools_globals',
        'endorsement.context_processors.is_desktop'

Add mock SAML attributes for the authenticated user runserver uses for default:

        LOGIN_URL = reverse_lazy('saml_login')
        LOGOUT_URL = reverse_lazy('saml_logout')
        MOCK_SAML_ATTRIBUTES = {
            'uwnetid': ['jstaff'],
            'affiliations': ['employee', 'member'],
            'eppn': ['[email protected]'],
            'scopedAffiliations': ['[email protected]', '[email protected]'],
            'isMemberOf': ['u_test_group', 'u_test_another_group',
                   'u_acadev_provision_support'],
        }

Add variables for safe email backend to test notifications

        EMAIL_BACKEND = 'saferecipient.EmailBackend'
        EMAIL_HOST = 'appsubmit.cac.washington.edu'
        EMAIL_NOREPLY_ADDRESS = 'Service Endorsement <[email protected]>'
        SAFE_EMAIL_RECIPIENT = '[email protected]'

And finally add and edit the filename paths as desired:

        MEDIA_URL = '/media/'
        MEDIA_ROOT = 'media/'
        STATIC_URL = '/static/'
        STATIC_ROOT = '/tmp/static'

        STATICFILES_FINDERS = (
            "django.contrib.staticfiles.finders.FileSystemFinder",
            "django.contrib.staticfiles.finders.AppDirectoriesFinder",
            "compressor.finders.CompressorFinder",
        )

        STATICFILES_DIRS = (
            os.path.join(BASE_DIR, 'static'),
        )

        SUPPORTTOOLS_PARENT_APP = "Svc En't"
        SUPPORTTOOLS_PARENT_APP_URL = "/"

        # django mobileesp
        from django_mobileesp.detector import mobileesp_agent as agent
        DETECT_USER_AGENTS = {
            'is_tablet': agent.detectTierTablet,
            'is_mobile': agent.detectMobileQuick,
        }

        COMPRESS_ROOT = "/tmp/"
        COMPRESS_PRECOMPILERS = (
            ('text/less', 'lessc {infile} {outfile}'),
            ('text/x-sass', 'pyscss {infile} > {outfile}'),
            ('text/x-scss', 'pyscss {infile} > {outfile}'),
        )
        COMPRESS_ENABLED = False
        COMPRESS_OFFLINE = False

        AUTHENTICATION_BACKENDS = [
            'django.contrib.auth.backends.RemoteUserBackend',
        ]

        AUTHZ_GROUP_BACKEND = 'authz_group.authz_implementation.all_ok.AllOK'
        USERSERVICE_ADMIN_GROUP = ''
        RESTCLIENTS_ADMIN_GROUP = ''
        RESTCLIENTS_DAO_CACHE_CLASS = 'restclients_core.cache.NoCache'

        LOGGING = {
            'version': 1,
            'disable_existing_loggers': False,
            'formatters': {
                'verbose': {
                    'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
                },
                'simple': {
                    'format': '%(asctime)s %(levelname)s %(message)s'
                },
            },
            'filters': {
                'require_debug_false': {
                    '()': 'django.utils.log.RequireDebugFalse'
                }
            },
            'handlers': {
                'endorsements_file': {
                    'level': 'DEBUG',
                    'formatter': 'simple',
                    'class': 'logging.handlers.TimedRotatingFileHandler',
                    'filename': '/tmp/endorsements.log',
                    'when': 'midnight',
                    'interval': 1,
                    'backupCount': 7
                },
                'sws_file': {
                    'level': 'DEBUG',
                    'formatter': 'simple',
                    'class': 'logging.handlers.TimedRotatingFileHandler',
                    'filename': '/tmp/sws_client.log',
                    'when': 'midnight',
                    'interval': 1,
                    'backupCount': 7
                },
                'gws_file': {
                    'level': 'DEBUG',
                    'formatter': 'simple',
                    'class': 'logging.handlers.TimedRotatingFileHandler',
                    'filename': '/tmp/gws_client.log',
                    'when': 'midnight',
                    'interval': 1,
                    'backupCount': 7
                },
                'pws_file': {
                    'level': 'DEBUG',
                    'formatter': 'simple',
                    'class': 'logging.handlers.TimedRotatingFileHandler',
                    'filename': '/tmp/pws_client.log',
                    'when': 'midnight',
                    'interval': 1,
                    'backupCount': 7
                },
                'mail_admins': {
                    'level': 'ERROR',
                    'filters': ['require_debug_false'],
                    'class': 'django.utils.log.AdminEmailHandler'
                },
            },
            'loggers': {
                'sws': {
                    'handlers': ['sws_file'],
                    'level': 'DEBUG'
                },
                'gws': {
                    'handlers': ['gws_file'],
                    'level': 'DEBUG'
                },
                'pws': {
                    'handlers': ['pws_file'],
                    'level': 'DEBUG'
                },
                'endorcements': {
                    'handlers': ['endorsements_file'],
                    'level': 'DEBUG'
                },
                'django.request': {
                    'handlers': ['mail_admins'],
                    'level': 'ERROR',
                    'propagate': True,
                },
            }
        }
  1. Update project/urls.py by changing it to:
        from django.conf.urls import url, include
        #from django.contrib import admin

        urlpatterns = [
            #url(r'^admin/', admin.site.urls),
            url(r'^saml/', include('uw_saml.urls')),
            url(r'^support', include('userservice.urls')),
            url(r'^logging/', include('django_client_logger.urls')),
            url(r'^', include('endorsement.urls')),
        ]
  1. Set the environment variable

    $ export DJANGO_SETTINGS_MODULE=project.settings

  2. Set up the database >$ ./manage.py migrate

  3. Run your development server: >$ export REMOTE_USER=jstaff

 >$ `./manage.py runserver 0.0.0.0:<your port>`