"""
://www.youtube.com/watch?v=26Ofj4hOVpA'ajk
Django settings for mysite project.

Generated by 'django-admin startproject' using Django 1.9.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

import os
import sys
import environ
from django.contrib.messages import constants as message_constants

# reading .env file
environ.Env.read_env()

env = environ.Env()

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#print("base dir path: ", BASE_DIR)

# NOTE: do NOT put these files in static, since collectstatic may make duplicate copies that .gitignore won't know about.  We don't want these in any repo.
FIREBASE_DEVELOPMENT_SERVER_CREDENTIALS_PATH = os.path.join(BASE_DIR,"mysite","firebaseCredentials","server", "ideatreetest-firebase-adminsdk-uzpso-e26c9a0786.json")
FIREBASE_PRODUCTION_SERVER_CREDENTIALS_PATH = os.path.join(BASE_DIR,"mysite","firebaseCredentials","server", "firebase-ideatree-firebase-adminsdk-sdttv-767ebd0cc8.json")

FIREBASE_DEVELOPMENT_CLIENT_CREDENTIALS_PATH = os.path.join(BASE_DIR,"mysite","firebaseCredentials","client", "initFirebaseCLIENT_DEVELOPMENT.js")
FIREBASE_PRODUCTION_CLIENT_CREDENTIALS_PATH = os.path.join(BASE_DIR,"mysite","firebaseCredentials","client", "initFirebaseCLIENT_PRODUCTION.js")


# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# SEE ALL the 'DEVEL' FLAGS below AND IN itreeFirebase.py!
# IMPORTANT.  If you use either the test or the production Firebase, and don't have a cron job running to clean up expired data them
# (see ideatree/management/commands/dbGarbageCollect.py), you may incur LARGE DATA CHARGES from Firebase.  YOU HAVE BEEN WARNED.
# See https://pamartinezandres.com/lessons-learnt-the-hard-way-using-firebase-realtime-database-c609b52b9afb 

# REMEMBER: if you change USE_DEVEL_FIREBASE_SITE to False - and thus are sending change messages to the production Firebase site - but you're
# on a local development environment, you're on a local database with its own map IDs, and so you're sending change messages into listening
# clients worldwide that shouldn't have access to your local database! (Nor you to theirs.)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

SECURE_CONTENT_TYPE_NOSNIFF = True

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG=env('DEBUG')
DEBUG=False
#print("DEBUG:", DEBUG, file=sys.stderr)

#USE_FIREBASE = False # DEVEL  # FIXME: it won't work without Firebase.
USE_FIREBASE = True 

# If True, uses the test FB site, rathern than the LIVE firebase site.
# !!!!!!!!!!!!!!!!!!!! Using the live site WILL INTERFERE WITH PRODUCTION USERS WHO HAVE THE SAME MAP IDs!!
USE_DEVEL_FIREBASE_SITE = env('USE_DEVEL_FIREBASE_SITE')
USE_DEVEL_FIREBASE_SITE = False #FIXME URGENT:  bug in environ: booleans aren't read correctly when using Apache
#print("USE_DEVEL_FIREBASE_SITE:", USE_DEVEL_FIREBASE_SITE, file=sys.stderr)

#ACCOUNT_SIGNUP_FORM_CLASS = 'ideatree.forms.MyCustomSignupForm'  # For older versions?  Doesn't work.
ACCOUNT_FORMS = {'signup':'ideatree.forms.MyCustomSignupForm'}

RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY')
RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY')
# Alternate in case google domain is not available.
RECAPTCHA_DOMAIN = 'www.recaptcha.net'  


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

APACHEUSERNAME = "www_data"




# ------------------ Installation-specific settings  -------------------------------------------------------------

# Ensure the SITE_ID corresponds to the row in the database for the site. (for allauth app) 
SITE_ID=int(env('SITE_ID'))
#print("Site ID for allauth:", str(SITE_ID), file=sys.stderr)




# If using AWS SES to send email, this address must be validated in the region listed in AWS_SES_REGION_NAME.
DEFAULT_FROM_EMAIL = env('DEFAULT_FROM_EMAIL')

# FIXME redundant
EMAIL_OF_IDEATREE = env('EMAIL_OF_IDEATREE')


VIDEOREGEX = {"youtube" : {
			"embed": '^.*//.*youtube\.com/embed/(.+?)\".*$',
			"share": '^.*//youtu\.be/(.+)\s*$',
			"URI": '^.*//www\.youtube\.com\/watch\?v=(.+?)\s*$'},
	"vimeo": { 
			"embed": '^.*\/\/player\.vimeo\.com\/video\/([0-9]+).*',
			"link": '^.*vimeo\.com\/[a-zA-Z\/]*([0-9]+)$'} }


FREE_ACCT_TRIALPERIOD_DAYS = 20
FREE_ACCT_GRACEPERIOD_DAYS = 10
FREE_ACCT_TIME_TILL_DELETION= 60 # additional time after disabling at trial+grace period  # FIXME: implement deletion cron job 

INACTIVE_USER_DELETION_DELAY_DAYS = 60	# FIXME: implement deletion cron job 

# To prevent problems with non-unique usernames or emails, we require that the administrator set this by explicitly looking at the database.
GUEST_USER_ID = int(env('GUEST_USER_ID'))

DEMO_MAPNAME = "Demo Map"

FREE_ACCT = 'F'
REGULAR_ACCT = 'R'
PREMIUM_ACCT  = 'P'

#FIXME: duplicates
ANALYSIS_DEVELOPMENT_PRICE = '4' 
PREMIUM_ACCT_PRICE  = '4' 

# FIXME: PREMIUM and REGULAR are used interchangeably in views.py
FREE_USER_NUM_MAPS_ALLOWED = 5
PREMIUM_USER_NUM_MAPS_ALLOWED = 50

MAX_FREE_ACCOUNT_NODES_PER_MAP = 50 
MAX_PREMIUM_ACCOUNT_NODES_PER_MAP = 1000

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'ideatree',
    'USER': env('DATABASE_USERNAME'),
    'PASSWORD': env('DATABASE_PASSWORD'), 
    #'HOST': '147.182.198.235',
    'HOST': 'localhost',
    'PORT': '5432',
}
}

SECRET_KEY= env('SECRET_KEY') 

# NOTE: When the user first signs up for a free account, a customer account is created on Stripe, so if you test Stripe with a user that you created
# administratively without going through the usual process, Stripe won't work.
PAYMENT_PROCESSOR_NAME = env('PAYMENT_PROCESSOR_NAME') 
STRIPE_IDEATREE_ACCOUNT_ID = env('STRIPE_IDEATREE_ACCOUNT_ID') 
STRIPE_API_KEY = env('STRIPE_API_KEY') 
STRIPE_PRICE_ID = env('STRIPE_PRICE_ID') 
STRIPE_WEBHOOK_SECRET = env('STRIPE_WEBHOOK_SECRET') 

MAILCHIMP_LIST_NAME = env('MAILCHIMP_LIST_NAME') 
MAILCHIMP_API_KEY = env('MAILCHIMP_API_KEY') 
MAILCHIMP_SITE_ADMIN_USERNAME = env('MAILCHIMP_SITE_ADMIN_USERNAME') 
MAILLIST_NEW_CUSTOMER_CHECK_INTERVAL_SECONDS = env('MAILLIST_NEW_CUSTOMER_CHECK_INTERVAL_SECONDS') 

EMAIL_BACKEND= env('EMAIL_BACKEND') 

#AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID') 
#AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY') 

 #AWS_SES_REGION_NAME = env('AWS_SES_REGION_NAME') 
 #AWS_SES_REGION_ENDPOINT = env('AWS_SES_REGION_ENDPOINT') 
# FIXME: enable DKIM on Amazon AWS SES

DATABASE_PASSWORD = env('DATABASE_PASSWORD') 
GUEST_USERNAME = env('GUEST_USERNAME') 
ACCOUNT_USERNAME_BLACKLIST= env('ACCOUNT_USERNAME_BLACKLIST') 
GUEST_PASSWORD = env('GUEST_PASSWORD') 

#RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY') 
#RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY') 
#RECAPTCHA_USE_SSL = env('RECAPTCHA_USE_SSL') # Defaults to False   #DEVEL
NOCAPTCHA = int(env('NOCAPTCHA')) 


# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
# And http://stackoverflow.com/questions/35858040/django-allowed-hosts-for-amazon-elb
ALLOWED_HOSTS = env('ALLOWED_HOSTS').split(':')


# ------------------ END Installation-spefic settings.  --------------------------------------------------------



# Security Settings --------------------------------------------------------------
CONFIRM_DELETE_PHRASE = "REALLY CANCEL"

# Set to true if SESSION_ENGINE is set to cookies.
#SESSION_COOKIE_HTTPONLY= True #production

SESSION_EXPIRE_AT_BROWSER_CLOSE = True
#SESSION_COOKIE_SECURE = True #DEVEL
#CSRF_COOKIE_SECURE = True # DEVEL
#SECURE_HSTS_SECONDS = 3600  # DEVEL # FIXME: increase to 1 year once it's clear that all resources load correctly
#SECURE_HSTS_INCLUDE_SUBDOMAINS = True #DEVEL


# Custom allauth settings
#ACCOUNT_SIGNUP_FORM_CLASS = 'ideatree.forms.MyCustomSignupForm'
ACCOUNT_FORMS = {'signup':'ideatree.forms.MyCustomSignupForm'}
# For docs, see: http://django-allauth.readthedocs.io/en/latest/configuration.html
#ACCOUNT_ADAPTER = 'ideatree.users.adapter.MySocialAccountAdapter'
# Use email as the primary identifier
ACCOUNT_AUTHENTICATION_METHOD = 'email' 
ACCOUNT_EMAIL_REQUIRED = True
# Make email verification mandatory to avoid junk email accounts
ACCOUNT_EMAIL_VERIFICATION = 'mandatory' 
#ACCOUNT_EMAIL_VERIFICATION = 'none'  
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL="/accounts/login/"
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL="/accounts/email/"
ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username'
ACCOUNT_USERNAME_REQUIRED = True 
ACCOUNT_LOGOUT_REDIRECT_URL ="/ideatree/"

LOGIN_REDIRECT_URL='/ideatree/map/'

# For @login_required decorators
LOGIN_URL = '/accounts/login/'



# Required by django-allauth in order to extend the sign up form to include profile data
# FIXME: apparently not true, since I've been including profile data using allauth signals
#ACCOUNT_SIGNUP_FORM_CLASS = 'ideatree.forms.SignupForm'
#SOCIALACCOUNT_AUTO_SIGNUP = False

ACCOUNT_EMAIL_SUBJECT_PREFIX = '[Ideatree]' 

SOCIALACCOUNT_QUERY_EMAIL=True

ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" # production
#ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http" # DEVEL
SOCIALACCOUNT_PROVIDERS = {
	'linkedin': {
		#'HEADERS': { 'x-li-src': 'msdk' },
		'SCOPE': [ 'r_emailaddress', 'r_basicprofile', ],
		'PROFILE_FIELDS': ['email-address', ]
	#	'id','first-name', 'last-name', 'email-address', ]
	}
}


# Application definition
INSTALLED_APPS = [
    'captcha',  
    # Required by allauth:
    'django.contrib.sites',
    'django.contrib.auth',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    # Others:
    'django_tables2',
    'django.contrib.humanize',
    #'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.linkedin_oauth2',
    'django.contrib.admin',
    'ideatree',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'paypal.standard.ipn',
]

#PAYPAL_RECEIVER_EMAIL = 'XXXXX'
#PAYPAL_TEST = True

# NOTE not for production
#CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } }


MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
# You should only use cache-based sessions if you’re using the Memcached or Redis cache backend.  See the Django docs.
#SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'  # test with Apache2 before deploying!
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
SESSION_FILE_PATH = '/var/www/ideatree/sessions'


ROOT_URLCONF = 'mysite.urls'


# IMPORTANT NOTE:  the order of directors in 'DIRS' matters!  They are accessed by subscript in views.py.
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,'ideatree','templates','ideatree'), os.path.join(BASE_DIR,'ideatree','templates','ideatree','allauth'), os.path.join(BASE_DIR,'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                # for allauth and django_tables2:
                'django.template.context_processors.request',
            ],
        },
    },
]

from django.contrib.messages import constants as message_constants
MESSAGE_LEVEL = message_constants.DEBUG

# Assumes there's a wsgi directory on sys.path containing a wsgi.py file containing an application variable.
WSGI_APPLICATION = 'wsgi.wsgi.application'

"""
LOGGING = {
  'version': 1,
  'disable_existing_loggers': False,
  'handlers': {
    'file': {
    'level': 'DEBUG',
    'class': 'logging.FileHandler',
    'filename': 'sql.log',
    },
  },
  'loggers': {
    'django.db.backends': {
    'handlers': ['file'],
    'level': 'DEBUG',
    'propagate': True,
    },
  },
}
"""

# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
# FIXME: test
AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'OPTIONS': { 'min_length': 12, }
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Add the 'allauth' backend to AUTHENTICATION_BACKEND and do not remove ModelBackend
AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin and to ensure compatibility with other packages
    'django.contrib.auth.backends.ModelBackend',
    # 'allauth' specific authentication methods
    'allauth.account.auth_backends.AuthenticationBackend',
)


# Taken from https://perishablepress.com/stop-using-unsafe-characters-in-urls/
URL_SAFETY_REGEX = "[0-9a-zA-Z$-_.+!*'(),,;/?:@=&]*"  # FIXME: is semi-colon really safe?
STRING_SAFETY_REGEX = "[0-9a-zA-Z$-_.+!*'(),,;/?:@=&]*"  # FIXME: is semi-colon really safe?
#STRING_SAFETY_REGEX ='^\w+$'

# Internationalization
LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
# Should be empty until development time.  See https://docs.djangoproject.com/en/2.2/ref/settings/#static-root
STATIC_ROOT = os.path.join(BASE_DIR,"static")

# FIXME: this is inaccurate:
MEDIA_ROOT = os.path.join(BASE_DIR,'ideatree','templates','ideatree','output')

# Good idea, but causes tests and collectstatic to fail:
#STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'

DOTS_PER_INCH = 72 # 96 will cause ps2 generation to fail at 200x200 largest size 
#DOTS_PER_INCH = 96 

# for outline (text only) view of a map
OUTLINE_NODE_LABEL_LENGTH = 17
OUTLINE_EDGE_LABEL_LENGTH = 12

NODE_LABEL_LENGTH = 64 # was 255. To avoid Graphviz "label too long" warnings, label length has been reduced and graphviz' 'fixedsize' parameter set to false.
LABELSHOWLEN = 35
CLUSTER_LABEL_LENGTH = 25
CLUSTER_LABEL_WIDTH_INCHES = "2" 
CLUSTER_LABEL_FONTSIZE = "12.0"  # in graphviz points
CLUSTER_INVISIBLE_NODE_FOR_EDGE_PLACEMENT = "tempinparent"

MAPNAME_TRUNCATED_LENGTH = 25
MAPDESCLEN = 55
USER_DEFAULT_MAP_SETTINGS ='{"view.nodeMaximization.smooth":false}'
PROVISIONAL_SECONDS_TO_STALE = 3600

FRIEND_ACCEPTED = 'A'
FRIEND_INVITED = 'I'
FRIEND_DECLINED = 'N'
FRIEND_DELETED = 'D'

#FIXME delete if possible
MAPMEMBERSHIP_VIEW = 'V'
MAPMEMBERSHIP_HIDE = 'H'

MAPMEMBERSHIP_ACTIVE = 'A'
MAPMEMBERSHIP_DELETED = 'D'

MAP_ACTIVE = 'A' 
MAP_DELETED = 'D' 
MAP_MARKED_FOR_DELETION = "M"


APPNAME = "ideatree"
OUTPUTDIRNAME = "output"
EXPORTS_DIRNAME = "exports"
PUBLISH_DIRNAME = "publish"
PUBLISH_DIR_PATH = os.path.join(STATIC_ROOT,PUBLISH_DIRNAME) 
GVPR_FLIPY_PATH = os.path.join(BASE_DIR,"ideatree","utils","flipY.gvpr")

# FIXME remove:
#PRODUCTION_PUBLISH_DIR_NAME = os.path.join(STATIC_ROOT,"ideatree","publish")

IMPORTS_DIRNAME = "imports"
READ_ONLY_DIRECTORY_NAME = "ROideatree"
MAP_DOWNLOAD_DIR = "downloads" 

PROVISIONAL = "P"

WHAT_AN_EDGE_IS_CALLED = "arrow"
WHAT_A_GRAPH_IS_CALLED = "map"
WHAT_A_NODE_IS_CALLED = "node"

MAP_FULL_PROMPT = "<div class='sizeText120percent leftText'>Sorry, this "+ WHAT_A_GRAPH_IS_CALLED+" has reached the size limit.<p>You may either:<ol><li>Delete one topic, then create a Tunnel to a new "+ WHAT_A_GRAPH_IS_CALLED +" and continue working, OR<li>Make room in this "+ WHAT_A_GRAPH_IS_CALLED +" by copying and pasting " + WHAT_A_NODE_IS_CALLED +"s to another "+ WHAT_A_GRAPH_IS_CALLED+"</ol></div>"
PLEASE_OPEN_GRAPH_PROMPT = "Please open a "+ WHAT_A_GRAPH_IS_CALLED +" first."
MUST_OWN_GRAPH_PROMPT = "You can only delete " + WHAT_A_GRAPH_IS_CALLED + "s that you personally created."
DELETE_AFTER_GRAPH_EMPTY_PROMPT = "After this "+ WHAT_A_GRAPH_IS_CALLED + " has had all " + WHAT_A_NODE_IS_CALLED +"s removed you can delete the "+ WHAT_A_GRAPH_IS_CALLED+ " here."
# NOTE: brackets '[]' or parentheses '()' in the following may break unit tests:
NOT_PERMITTED_PROMPT = "Sorry, someone - the "+ WHAT_A_GRAPH_IS_CALLED +" owner or<br/>administrator - has to give you permission for this action."
PERMISSION_DENIED_PROMPT = "You don't currently have access to this "+ WHAT_A_GRAPH_IS_CALLED +". Please either: 1) Open a different "+ WHAT_A_GRAPH_IS_CALLED +", OR 2) Click the Back button to return to where you were."

PATH_BEGIN_NODE = "B"
PATH_END_NODE = "E"
PATH_ORIGIN_LABEL = "PATH ORIGIN"
PATH_END_LABEL = "PATH END"
# NOTE: just here to shorten a DB query in views.py: 
PATH_ENDPOINT_NODE_TYPES = [PATH_BEGIN_NODE, PATH_END_NODE]

#FIXME: load as map default for client:
PATH_ENDPOINT_NODE_FILLCOLOR = "rgba(00,51,204,255)" #FIXME: shouldn't this be in hex, saved in the canonical db, and the client converts as it needs to?
PATH_ENDPOINT_NODE_FONTCOLOR = "rgba(00,51,204,255)"

ORIGINAL_NODE = "O" # FIXME: rename
EMPTY_NODE_LABEL_PLACEHOLDER = "HOVER HERE"
NODE_DELETED = "D"
NODE_ACTIVE = "A"
NODE_MARKED_FOR_DELETION = "M"
DEFAULTNODE_PENCOLOR = "000000"
DEFAULTNODE_STYLE = ORIGINAL_NODE
NODE_DESCRIPTION_LENGTH  = 4096
NODE_URLFIELD_LENGTH = 1024
NODE_SHAPES = ["rect", "box","polygon", "ellipse", "oval", "circle", "point", "egg", "triangle", "plaintext", "diamond", "trapezium", "parallelogram", "house", "pentagon", "hexagon", "septagon", "octagon", "doublecircle", "doubleoctagon", "tripleoctagon", "invtriangle", "invtrapezium", "invhouse", "Mdiamond", "Msquare", "Mcircle", "rectangle", "square", "star", "none", "note", "tab", "folder", "box3d", "component", "promoter", "cds", "terminator", "utr", "primersite", "restrictionsite", "fivepoverhang", "threepoverhang", "noverhang", "assembly", "signature", "insulator", "ribosite", "rnastab", "proteasesite", "proteinstab", "rpromoter", "rarrow", "larrow", "lpromoter"]

DEFAULTEDGE_PENCOLOR = "000000" 
DEFAULTEDGE_ARROWHEAD_STYLE = 0 
DEFAULTEDGE_PENWIDTH = "1.0" 
DEFAULTEDGE_COST = 0
EDGE_FONTNAME= "DejaVuSans.ttf"  # FIXME: Nimbus_sans may be needed for exporting pdf, and is hardwired in
EDGE_ACTIVE = "A"
EDGE_DELETED = "D"
EDGE_MARKED_FOR_DELETION = "M"
EDGE_PROVISIONAL = "P"
EDGE_ANALYSIS_COLOR = "990000ff"
EDGE_ANALYSIS_PENWIDTH = "3.0"


VOTABLE_NODE_COLOR = "CD3700"  # orangered3 
VOTABLE_NODE = "S"  # FIXME: client uses 'V' to mean video node, so we can't use it here.
DEFAULT_VOTABLE_NODE_LABEL = "PLEASE VOTE"
# FIXME: why are these different from Node statusii?  This complicates garbage collection.
VOTABLE_ACTIVE = "A"
VOTABLE_DELETED = "D"
VOTABLE_STATUS_CHOICES =  (
    (VOTABLE_ACTIVE, "Active"),
    (VOTABLE_DELETED, "Deleted"),
)

# FIXME: why are these different from Node statusii?  This complicates garbage collection.
TUNNEL_ACTIVE = "A"
TUNNEL_DELETED = "D"

WHAT_A_CLUSTER_IS_CALLED = "Cluster"
CLUSTER = "C" 
DEFAULT_CLUSTER_LABEL = "Cluster"
DEFAULT_CLUSTER_FILLCOLOR = "CFA700FF"  # bronze 

TUNNELNODECOLOR = "444444" 
DEFAULT_TUNNEL_LABEL = "Tunnel" 
TUNNEL_NODE = "T"
TUNNEL_PENCOLOR = "000000"


# FIXME: document the reason for having both NODE_DELETED and NODE_MARKED_FOR_DELETION. Same for maps and edges.
NODE_STATUS_CHOICES =  (
    (NODE_ACTIVE, "Active"),
    (NODE_DELETED, "Deleted"),
    (NODE_MARKED_FOR_DELETION, "Marked for deletion"),
)
# FIXME: put provisional as a status, not a type, to make it consistent with edges and comments.
NODE_TYPE_CHOICES =  (
    (PROVISIONAL, "Provisional"),
    (ORIGINAL_NODE, "Regular Node"),
    (TUNNEL_NODE, "Tunnel"),
    (CLUSTER, "Cluster Node"),
    (VOTABLE_NODE, "Votable"),
		(PATH_BEGIN_NODE, "Path Origin Node"),
		(PATH_END_NODE, "Path End Node")
)

NODE_COMMENT_ACTIVE = "A"
NODE_COMMENT_DELETED = "D"
NODE_COMMENT_MARKED_FOR_DELETION= "M"


LEFTRIGHT = "LR"
RIGHTLEFT = "RL"
TOPBOTTOM = "TB"
BOTTOMTOP = "BT"

MAP_LAYOUT_ORIENTATIONS =  (
    (LEFTRIGHT, "Left-Right"),
    (RIGHTLEFT, "Right-Left"),
    (TOPBOTTOM, "Top-Bottom"),
    (BOTTOMTOP, "Bottom-Top"),
)

DEFAULT_MAP_LAYOUT_ORIENTATION = LEFTRIGHT

DEFAULT_LAYOUT_ENGINE = "dot"
NODE_PINNED_LAYOUT_ENGINE = "neato"
CIRCULAR_LAYOUT_ENGINE = "circo"
RADIAL_LAYOUT_ENGINE = "twopi"

 
MAPBACKGROUND = "FFFFFF"

DEFAULTLABELS = {ORIGINAL_NODE:EMPTY_NODE_LABEL_PLACEHOLDER, VOTABLE_NODE:DEFAULT_VOTABLE_NODE_LABEL, CLUSTER:DEFAULT_CLUSTER_LABEL, TUNNEL_NODE:DEFAULT_TUNNEL_LABEL }

EDGEFONTSIZE = "12.0" # In graphviz points
NODEFONTSIZE = "24.0"

GRAPHVIZ_GV = "gv"
GRAPHVIZ_DOT = "dot"
GRAPHVIZ_OUTPUT_FILE_SUFFIX = "json"
MAPLOAD_TEMP_FILE_SUFFIX = "json"

CSV_FILE_SUFFIX = "csv"
PUBLISH_FILE_SUFFIX = "pdf" # FIXME: make this automatically propagate to js/initShowMenus.js
EXCEL_FILE_SUFFIX = "xlsx"
OUTLINE_FILETYPE = "html"

VALID_IMPORT_FORMATS = [GRAPHVIZ_GV,GRAPHVIZ_DOT,EXCEL_FILE_SUFFIX]

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

