<file_sep>import os
from global_settings import PROJECT_PATH, LOGGING

# Uncomment to put the application in non-debug mode. This is useful
# for testing error handling and messages.
# DEBUG = False
# TEMPLATE_DEBUG = DEBUG

# Override this to match the application endpoint
# FORCE_SCRIPT_NAME = ''

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(PROJECT_PATH, 'fabrydb.db')
    }
}

# Non-restricted email port for development, run in a terminal:
# python -m smtpd -n -c DebuggingServer localhost:1025
EMAIL_PORT = 1025
EMAIL_SUBJECT_PREFIX = '[fabrydb] '

# This is used as a "seed" for various hashing algorithms. This must be set to
# a very long random string (40+ characters)
SECRET_KEY = 'abc123'

# Uncomment for additional logging. If using the 'rotating_file' handler
# you must create the `logs` directory in the project root.
# LOGGING['handlers'].update({
#     'stdout': {
#         'class': 'logging.StreamHandler',
#         'level': 'DEBUG',
#     },
#     'rotating_file': {
#         'class': 'logging.handlers.RotatingFileHandler',
#         'level': 'DEBUG',
#         'filename': os.path.join(PROJECT_PATH, 'logs/debug.log')
#         'maxBytes': 2048,
#         'backupCount': 5,
#     },
# })
# 
# LOGGING['loggers'].update({
#     'django.db.backends': {
#         'handlers': ['rotating_file'],
#         'propagate': True,
#         'level': 'DEBUG',
#     }
# })
<file_sep>import os
from global_settings import *

try:
    from local_settings import *
    from local_settings_secret import *
except ImportError:
    import warnings
    warnings.warn('Local settings have not been found (src.conf.local_settings). Trying to import Heroku config...')

    try:
        from local_settings_heroku import *
        from local_settings_heroku_secret import *
        warnings.warn('Local Heroku config loaded')

    except ImportError:
        warnings.warn('Heroku local settings not found neither (src.conf.local_settings_heroku)')


# FORCE_SCRIPT_NAME overrides the interpreted 'SCRIPT_NAME' provided by the
# web server. since the URLs below are used for various purposes outside of
# the WSGI application (static and media files), these need to be updated to
# reflect this alteration
if FORCE_SCRIPT_NAME:
    ADMIN_MEDIA_PREFIX = os.path.join(FORCE_SCRIPT_NAME, ADMIN_MEDIA_PREFIX[1:])

    STATIC_URL = os.path.join(FORCE_SCRIPT_NAME, STATIC_URL[1:])
    MEDIA_URL = os.path.join(FORCE_SCRIPT_NAME, MEDIA_URL[1:])

    LOGIN_URL = os.path.join(FORCE_SCRIPT_NAME, LOGIN_URL[1:])
    LOGOUT_URL = os.path.join(FORCE_SCRIPT_NAME, LOGOUT_URL[1:])
    LOGIN_REDIRECT_URL = os.path.join(FORCE_SCRIPT_NAME, LOGIN_REDIRECT_URL[1:])


# This is used as a "seed" for various hashing algorithms. This must be set to
# a very long random string (40+ characters)
SECRET_KEY = 'read from secret settings'

# Allow all host headers
ALLOWED_HOSTS = ['*']

# Static asset configuration
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_PATH, '_site/static')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
<file_sep>from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from fabrydb.models import Dadosgerais

@login_required
def home(request):
    n = Dadosgerais.objects.count()
    extra_context = {}
    extra_context['nb_patients'] = n
    return render(request, 'site/home_box.html', extra_context)
<file_sep>[program:fabrydb-local]
directory = /home/devuser/.virtualenvs/fabrydb-env/fabrydb
command = /home/devuser/.virtualenvs/fabrydb-env/bin/uwsgi --ini /home/devuser/.virtualenvs/fabrydb-env/fabrydb/server/uwsgi/local.ini
autostart = true
autorestart = true
<file_sep>Django==1.5.11
South==0.8.1
Whoosh==2.4.0
avocado==2.3.10
django-guardian==1.2.4
django-haystack==2.0.0
django-preserialize==1.0.7
jdcal==1.0
jsonfield==0.9.4
modeltree==1.1.8
openpyxl==2.1.1
psycopg2==2.5.4
restlib2==0.4.3
serrano==2.3.10
six==1.8.0
wsgiref==0.1.2
<file_sep>[program:fabrydb-production]
directory = /home/devuser/webapps/fabrydb-env/fabrydb
command = /home/devuser/webapps/fabrydb-env/bin/uwsgi --ini /home/devuser/webapps/fabrydb-env/fabrydb/server/uwsgi/production.ini
autostart = true
autorestart = true
<file_sep>/etc/init.d/development.ini<file_sep>import os
# from global_settings import PROJECT_PATH

# Uncomment to put the application in non-debug mode. This is useful
# for testing error handling and messages.
DEBUG = False
TEMPLATE_DEBUG = DEBUG

# Override this to match the application endpoint
FORCE_SCRIPT_NAME = ''

# Non-restricted email port for development, run in a terminal:
# python -m smtpd -n -c DebuggingServer localhost:1025
EMAIL_PORT = 1025
EMAIL_SUBJECT_PREFIX = '[fabrydb Local] '

# Parse database configuration from $DATABASE_URL
import dj_database_url

DATABASES = {}
DATABASES['default'] = dj_database_url.config()

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

# Static asset configuration
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = '/app/_site/static'
STATIC_URL = '/static/'

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

# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/


# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
# Staticfiles_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'

# This is used as a "seed" for various hashing algorithms. This must be set to
# a very long random string (40+ characters)
SECRET_KEY = 'secret'
<file_sep>Django==1.5.11
South==0.8.1
Whoosh==2.4.0
avocado==2.3.10
dj-database-url==0.3.0
django-guardian==1.2.4
django-haystack==2.0.0
django-preserialize==1.0.7
gunicorn==19.1.1
jdcal==1.0
jsonfield==0.9.4
modeltree==1.1.8
openpyxl==2.1.1
psycopg2==2.5.4
restlib2==0.3.9
serrano>=2.3.0,<2.4.0
six==1.8.0
whitenoise==1.0.5
wsgiref==0.1.2
<file_sep>from django.contrib import admin
from fabrydb.models import (AvaliacaoCardiologica, AvaliacaoNeurologica,
                            AvaliacaoOftalmologica, AvaliacaoRenal, Banco,
                            BioquimicaGeral, DadosDaInfusao, Dadosgerais,
                            MssiCardiologico, MssiGeral,
                            MssiNeurologicoPsiquiatrico, MssiRenal,
                            Questionarios)
from fabrydb.models import (Tiposecg, TiposecocardiogramaI, Tiposholter2H,
                            Tiposacroparestesia,
                            TiposangioressonanciaMagnetica,
                            Tiposcerebrovascular,
                            Tiposevidenciadedisfuncaorenal, Tiposgenotipagem,
                            TiposmedicacoesEmUso,
                            Tiposmodificacoesnaespessuramiocardio,
                            TiposreacaoPosInfusao,
                            TiposcondutaAReacaoPosInfusao,
                            TiposresultadoDaBiopsia, Tipossexo, Tiposvertigem)

# Custom admin console
class FabrydbAdminSite(admin.AdminSite):
    site_header = 'FaBRyDB'

fadmin = FabrydbAdminSite(name='fadmin')


# Registering models
class ListEcgInline(admin.TabularInline):
    model = AvaliacaoCardiologica.category_ecg.through


class ListEcocardiogramaiInline(admin.TabularInline):
    model = AvaliacaoCardiologica.category_ecocardiogramai.through


class ListHolter2hInline(admin.TabularInline):
    model = AvaliacaoCardiologica.category_holter2h.through


class ListDadosgeraisInline(admin.TabularInline):
    model = Dadosgerais.category_medicacoes_em_uso.through


class ListAvaliacaorenalInline(admin.TabularInline):
    model = AvaliacaoRenal.category_resultados_da_biopsia.through


class AvaliacaoCardiologicaAdmin(admin.ModelAdmin):
    list_display = ['id', 'data']
    list_filter = ['category_ecg', 'id']
    search_fields = ['id__nome']
    inlines = [ListEcgInline, ListEcocardiogramaiInline, ListHolter2hInline, ]


class DadosgeraisAdmin(admin.ModelAdmin):
    list_display = ['nome', 'data_de_nascimento', 'category_genotipagem']
    list_filter = ['sexo', 'etnia', 'category_genotipagem', 'nome']
    search_fields = ['nome']
    inlines = [ListDadosgeraisInline, ]


class DadosDaInfusaoAdmin(admin.ModelAdmin):
    list_display = ['id', 'data', 'category_reacao_pos_infusao',
                    'category_conduta_a_reacao_pos_infusao']
    list_filter = ['data', 'category_conduta_a_reacao_pos_infusao__descricao',
                   'category_reacao_pos_infusao__descricao', 'id']
    search_fields = ['id__nome']

    change_form_template = 'admin/change_computed_fields.html'

    def change_view(self, request, object_id, form_url='', extra_context=None):
        """Includes computed fields."""
        d = DadosDaInfusao.objects.get(pk = object_id)
        extra_context = extra_context or {}
        extra_context['infusao'] = d
        return super(DadosDaInfusaoAdmin, self).change_view(request, object_id,
            form_url, extra_context=extra_context)


class AvaliacaoRenalAdmin(admin.ModelAdmin):
    list_display = ['id', 'data', 'biopsia_renal']
    list_filter = ['biopsia_renal', 'id']
    search_fields = ['id__nome']
    inlines = [ListAvaliacaorenalInline, ]


class MssiCardiologicoAdmin(admin.ModelAdmin):
    list_display = ['id', 'data', 'modificacoes_na_espessura_do_miocardio']
    list_filter = ['modificacoes_na_espessura_do_miocardio',
                   'anormalidades_no_ecg', 'marcapasso', 'hipertensao', 'id']
    search_fields = ['id__nome']


class MssiRenalAdmin(admin.ModelAdmin):
    list_display = ['id', 'data', 'evidencia_de_disfuncao_renal']
    list_filter = ['evidencia_de_disfuncao_renal', 'id']
    search_fields = ['id__nome']


class AvaliacaoNeurologicaAdmin(admin.ModelAdmin):
    list_display = ['id', 'data', 'category_angioressonancia_magnetica']
    list_filter = ['category_angioressonancia_magnetica', 'id']
    search_fields = ['id__nome']


class AvaliacaoOftalmologicaAdmin(admin.ModelAdmin):
    list_display = ['id', 'data']
    list_filter = ['cornea_verticilata', 'tortuosidade_dos_vasos_retinianos',
                   'tortuosidade_dos_vasos_conjuntivais',
                   'opacidade_da_cornea', 'id']
    search_fields = ['id__nome']


class BioquimicaGeralAdmin(admin.ModelAdmin):
    list_display = ['id', 'data']
    list_filter = ['id']
    search_fields = ['id__nome']


class MssiGeralAdmin(admin.ModelAdmin):
    list_display = ['id', 'data']
    list_filter = ['aparencia_facial_caracteristica', 'angioqueratoma',
                   'edema', 'musculoesqueletico', 'cornea_verticilata',
                   'diaforese', 'dor_abdominal', 'diarreiaconstipacao',
                   'hemorroidas', 'pulmonar', 'nyha', 'id']
    search_fields = ['id__nome']


class MssiNeurologicoPsiquiatricoAdmin(admin.ModelAdmin):
    list_display = ['id', 'data']
    list_filter = ['vertigem', 'acroparestesia', 'crises_de_febre_e_dor',
                   'cerebrovascular', 'depressao', 'fadiga', 'hipoatividade',
                   'id']
    search_fields = ['id__nome']


fadmin.register(AvaliacaoCardiologica, AvaliacaoCardiologicaAdmin)
fadmin.register(AvaliacaoNeurologica, AvaliacaoNeurologicaAdmin)
fadmin.register(AvaliacaoOftalmologica, AvaliacaoOftalmologicaAdmin)
fadmin.register(AvaliacaoRenal, AvaliacaoRenalAdmin)
fadmin.register(Banco)
fadmin.register(BioquimicaGeral, BioquimicaGeralAdmin)
fadmin.register(DadosDaInfusao, DadosDaInfusaoAdmin)
fadmin.register(Dadosgerais, DadosgeraisAdmin)
fadmin.register(MssiCardiologico, MssiCardiologicoAdmin)
fadmin.register(MssiGeral, MssiGeralAdmin)
fadmin.register(MssiNeurologicoPsiquiatrico,
                    MssiNeurologicoPsiquiatricoAdmin)
fadmin.register(MssiRenal, MssiRenalAdmin)
fadmin.register(Questionarios)

fadmin.register(Tiposecg)
fadmin.register(TiposecocardiogramaI)
fadmin.register(Tiposholter2H)
fadmin.register(Tiposacroparestesia)
fadmin.register(TiposangioressonanciaMagnetica)
fadmin.register(Tiposcerebrovascular)
fadmin.register(Tiposevidenciadedisfuncaorenal)
fadmin.register(Tiposgenotipagem)
fadmin.register(TiposmedicacoesEmUso)
fadmin.register(Tiposmodificacoesnaespessuramiocardio)
fadmin.register(TiposreacaoPosInfusao)
fadmin.register(TiposcondutaAReacaoPosInfusao)
fadmin.register(TiposresultadoDaBiopsia)
fadmin.register(Tipossexo)
fadmin.register(Tiposvertigem)





admin.site.register(AvaliacaoCardiologica, AvaliacaoCardiologicaAdmin)
admin.site.register(AvaliacaoNeurologica, AvaliacaoNeurologicaAdmin)
admin.site.register(AvaliacaoOftalmologica, AvaliacaoOftalmologicaAdmin)
admin.site.register(AvaliacaoRenal, AvaliacaoRenalAdmin)
admin.site.register(Banco)
admin.site.register(BioquimicaGeral, BioquimicaGeralAdmin)
admin.site.register(DadosDaInfusao, DadosDaInfusaoAdmin)
admin.site.register(Dadosgerais, DadosgeraisAdmin)
admin.site.register(MssiCardiologico, MssiCardiologicoAdmin)
admin.site.register(MssiGeral, MssiGeralAdmin)
admin.site.register(MssiNeurologicoPsiquiatrico,
                    MssiNeurologicoPsiquiatricoAdmin)
admin.site.register(MssiRenal, MssiRenalAdmin)
admin.site.register(Questionarios)

admin.site.register(Tiposecg)
admin.site.register(TiposecocardiogramaI)
admin.site.register(Tiposholter2H)
admin.site.register(Tiposacroparestesia)
admin.site.register(TiposangioressonanciaMagnetica)
admin.site.register(Tiposcerebrovascular)
admin.site.register(Tiposevidenciadedisfuncaorenal)
admin.site.register(Tiposgenotipagem)
admin.site.register(TiposmedicacoesEmUso)
admin.site.register(Tiposmodificacoesnaespessuramiocardio)
admin.site.register(TiposreacaoPosInfusao)
admin.site.register(TiposcondutaAReacaoPosInfusao)
admin.site.register(TiposresultadoDaBiopsia)
admin.site.register(Tipossexo)
admin.site.register(Tiposvertigem)
<file_sep>from django import template
from django.conf import settings

register = template.Library()

@register.inclusion_tag('site/mailto_support.html')
def mailto_support():
    return  {"support_email": settings.SUPPORT_EMAIL }
