""" Django settings for MNF project. Generated by 'django-admin startproject' using Django 4.2.9. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from datetime import timedelta from pathlib import Path import os from dotenv import load_dotenv #import pandas as pd import datetime load_dotenv() api_key_free = os.environ.get("api_key_free") api_key = os.environ.get("api_key") org_id = os.environ.get("org_id") # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent def BasePath(): #/home/mnfbeta/mnf/app return str(BASE_DIR) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.environ.get("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = bool(os.environ.get("DEBUG", default=0)) ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",") # Application definition INSTALLED_APPS = os.environ.get('INSTALLED_APPS').split(',') MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware', 'allauth.account.middleware.AccountMiddleware', ] SITE_ID = 1 ROOT_URLCONF = 'MNF.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, "build")], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'MNF.wsgi.application' AUTHENTICATION_BACKENDS = ( 'allauth.account.auth_backends.AuthenticationBackend', 'django.contrib.auth.backends.ModelBackend', ) SOCIALACCOUNT_PROVIDERS = { "google": { "SCOPE": [ "profile", "email", ], "AUTH_PARAMS": { "access_type": "offline", }, }, } ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_VERIFICATION = 'optional' LOGIN_REDIRECT_URL = '/' # REQUIRED FOR GMAIL LOGIN # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # SECURE_SSL_REDIRECT = True # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': os.environ.get('ENGINE'), 'NAME': os.environ.get('DB_NAME'), 'USER':os.environ.get('DB_USER'), 'PASSWORD': os.environ.get('PASSWORD'), 'HOST': os.environ.get('HOST'), 'PORT': os.environ.get('PORT'), # 'OPTIONS': { # 'sslmode': 'disable', # } } } # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Kolkata' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_URL = '/static/' # STATICFILES_DIRS = [BASE_DIR / "static",] MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' print("STATIC_ROOT:",STATIC_ROOT) SECURE_PROXY_SSL_HEADER =("HTTP_X_FORWARDED_PROTO",'https') CSRF_TRUSTED_ORIGINS = [os.environ.get('CSRF_TRUSTED_ORIGINS')] # rest framework REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ], "DEFAULT_FILTER_BACKENDS": [ "django_filters.rest_framework.DjangoFilterBackend" ], 'DEFAULT_RENDERER_CLASSES': ['rest_framework.renderers.JSONRenderer'] } file_path = f"{BASE_DIR}/MNF/Pricing.xlsx" # rest_framework jwt SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(days=100), 'REFRESH_TOKEN_LIFETIME': timedelta(days=300), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': False, 'UPDATE_LAST_LOGIN': False, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'JWK_URL': None, 'LEEWAY': 0, 'AUTH_HEADER_TYPES': ('Bearer',), 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION', 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser', } # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' T_STRIPE_SECRET_KEY = os.environ.get('T_STRIPE_SECRET_KEY') STRIPE_SECRET_KEY = os.environ.get('STRIPE_SECRET_KEY') STRIPE_PUBLISHABLE_KEY = os.environ.get('STRIPE_PUBLISHABLE_KEY') T_STRIPE_PUBLISHABLE_KEY = os.environ.get('T_STRIPE_PUBLISHABLE_KEY') T_RAZORPAY_KEY_ID = os.environ.get('T_RAZORPAY_KEY_ID') T_RAZORPAY_KEY_SECRET = os.environ.get('T_RAZORPAY_KEY_SECRET') RAZORPAY_KEY_ID = os.environ.get('RAZORPAY_KEY_ID') RAZORPAY_KEY_SECRET = os.environ.get('RAZORPAY_KEY_SECRET') TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') TWILIO_PHONE_NUMBER = os.environ.get('TWILIO_PHONE_NUMBER') MONTHLY_MEMBER = int(os.environ.get('MONTHLY_MEMBER')) EMPLOY_DISCOUNT = int(os.environ.get('EMPLOY_DISCOUNT')) IM_DISCOUNT = int(os.environ.get('IM_DISCOUNT')) YEARLY_MEMBER = int(os.environ.get('YEARLY_MEMBER')) YEARLY_MEMBER_ADDITIONAL = int(os.environ.get('YEARLY_MEMBER_ADDITIONAL')) LIFE_MEMBER_ADDITIONAL = int(os.environ.get('LIFE_MEMBER_ADDITIONAL')) LIFE_MEMBER_YEAR = int(os.environ.get('LIFE_MEMBER_YEAR')) LIFE_MEMBER = int(os.environ.get('LIFE_MEMBER')) EARLY_BIRD = int(os.environ.get('EARLY_BIRD')) GST = int(os.environ.get('GST')) CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_METHODS = [ "DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT", ] COUNTRY_LIST = { "AD": "Andorra", "AE": "United Arab Emirates", "AF": "Afghanistan", "AG": "Antigua & Barbuda", "AI": "Anguilla", "AL": "Albania", "AM": "Armenia", "AN": "Netherlands Antilles", "AO": "Angola", "AQ": "Antarctica", "AR": "Argentina", "AS": "American Samoa", "AT": "Austria", "AU": "Australia", "AW": "Aruba", "AZ": "Azerbaijan", "BA": "Bosnia and Herzegovina", "BB": "Barbados", "BD": "Bangladesh", "BE": "Belgium", "BF": "Burkina Faso", "BG": "Bulgaria", "BH": "Bahrain", "BI": "Burundi", "BJ": "Benin", "BM": "Bermuda", "BN": "Brunei Darussalam", "BO": "Bolivia", "BR": "Brazil", "BS": "Bahama", "BT": "Bhutan", "BU": "Burma (no longer exists)", "BV": "Bouvet Island", "BW": "Botswana", "BY": "Belarus", "BZ": "Belize", "CA": "Canada", "CC": "Cocos (Keeling) Islands", "CF": "Central African Republic", "CG": "Congo", "CH": "Switzerland", "CI": "Côte D'ivoire (Ivory Coast)", "CK": "Cook Iislands", "CL": "Chile", "CM": "Cameroon", "CN": "China", "CO": "Colombia", "CR": "Costa Rica", "CS": "Czechoslovakia (no longer exists)", "CU": "Cuba", "CV": "Cape Verde", "CX": "Christmas Island", "CY": "Cyprus", "CZ": "Czech Republic", "DD": "German Democratic Republic (no longer exists)", "DE": "Germany", "DJ": "Djibouti", "DK": "Denmark", "DM": "Dominica", "DO": "Dominican Republic", "DZ": "Algeria", "EC": "Ecuador", "EE": "Estonia", "EG": "Egypt", "EH": "Western Sahara", "ER": "Eritrea", "ES": "Spain", "ET": "Ethiopia", "FI": "Finland", "FJ": "Fiji", "FK": "Falkland Islands (Malvinas)", "FM": "Micronesia", "FO": "Faroe Islands", "FR": "France", "FX": "France, Metropolitan", "GA": "Gabon", "GB": "United Kingdom (Great Britain)", "GD": "Grenada", "GE": "Georgia", "GF": "French Guiana", "GH": "Ghana", "GI": "Gibraltar", "GL": "Greenland", "GM": "Gambia", "GN": "Guinea", "GP": "Guadeloupe", "GQ": "Equatorial Guinea", "GR": "Greece", "GS": "South Georgia and the South Sandwich Islands", "GT": "Guatemala", "GU": "Guam", "GW": "Guinea-Bissau", "GY": "Guyana", "HK": "Hong Kong", "HM": "Heard & McDonald Islands", "HN": "Honduras", "HR": "Croatia", "HT": "Haiti", "HU": "Hungary", "ID": "Indonesia", "IE": "Ireland", "IL": "Israel", "IN": "India", "IO": "British Indian Ocean Territory", "IQ": "Iraq", "IR": "Islamic Republic of Iran", "IS": "Iceland", "IT": "Italy", "JM": "Jamaica", "JO": "Jordan", "JP": "Japan", "KE": "Kenya", "KG": "Kyrgyzstan", "KH": "Cambodia", "KI": "Kiribati", "KM": "Comoros", "KN": "St. Kitts and Nevis", "KP": "Korea, Democratic People's Republic of", "KR": "Korea, Republic of", "KW": "Kuwait", "KY": "Cayman Islands", "KZ": "Kazakhstan", "LA": "Lao People's Democratic Republic", "LB": "Lebanon", "LC": "Saint Lucia", "LI": "Liechtenstein", "LK": "Sri Lanka", "LR": "Liberia", "LS": "Lesotho", "LT": "Lithuania", "LU": "Luxembourg", "LV": "Latvia", "LY": "Libyan Arab Jamahiriya", "MA": "Morocco", "MC": "Monaco", "MD": "Moldova, Republic of", "MG": "Madagascar", "MH": "Marshall Islands", "ML": "Mali", "MN": "Mongolia", "MM": "Myanmar", "MO": "Macau", "MP": "Northern Mariana Islands", "MQ": "Martinique", "MR": "Mauritania", "MS": "Monserrat", "MT": "Malta", "MU": "Mauritius", "MV": "Maldives", "MW": "Malawi", "MX": "Mexico", "MY": "Malaysia", "MZ": "Mozambique", "NA": "Namibia", "NC": "New Caledonia", "NE": "Niger", "NF": "Norfolk Island", "NG": "Nigeria", "NI": "Nicaragua", "NL": "Netherlands", "NO": "Norway", "NP": "Nepal", "NR": "Nauru", "NT": "Neutral Zone (no longer exists)", "NU": "Niue", "NZ": "New Zealand", "OM": "Oman", "PA": "Panama", "PE": "Peru", "PF": "French Polynesia", "PG": "Papua New Guinea", "PH": "Philippines", "PK": "Pakistan", "PL": "Poland", "PM": "St. Pierre & Miquelon", "PN": "Pitcairn", "PR": "Puerto Rico", "PT": "Portugal", "PW": "Palau", "PY": "Paraguay", "QA": "Qatar", "RE": "Réunion", "RO": "Romania", "RU": "Russian Federation", "RW": "Rwanda", "SA": "Saudi Arabia", "SB": "Solomon Islands", "SC": "Seychelles", "SD": "Sudan", "SE": "Sweden", "SG": "Singapore", "SH": "St. Helena", "SI": "Slovenia", "SJ": "Svalbard & Jan Mayen Islands", "SK": "Slovakia", "SL": "Sierra Leone", "SM": "San Marino", "SN": "Senegal", "SO": "Somalia", "SR": "Suriname", "ST": "Sao Tome & Principe", "SU": "Union of Soviet Socialist Republics (no longer exists)", "SV": "El Salvador", "SY": "Syrian Arab Republic", "SZ": "Swaziland", "TC": "Turks & Caicos Islands", "TD": "Chad", "TF": "French Southern Territories", "TG": "Togo", "TH": "Thailand", "TJ": "Tajikistan", "TK": "Tokelau", "TM": "Turkmenistan", "TN": "Tunisia", "TO": "Tonga", "TP": "East Timor", "TR": "Turkey", "TT": "Trinidad & Tobago", "TV": "Tuvalu", "TW": "Taiwan, Province of China", "TZ": "Tanzania, United Republic of", "UA": "Ukraine", "UG": "Uganda", "UM": "United States Minor Outlying Islands", "US": "United States of America", "UY": "Uruguay", "UZ": "Uzbekistan", "VA": "Vatican City State (Holy See)", "VC": "St. Vincent & the Grenadines", "VE": "Venezuela", "VG": "British Virgin Islands", "VI": "United States Virgin Islands", "VN": "Viet Nam", "VU": "Vanuatu", "WF": "Wallis & Futuna Islands", "WS": "Samoa", "YD": "Democratic Yemen (no longer exists)", "YE": "Yemen", "YT": "Mayotte", "YU": "Yugoslavia", "ZA": "South Africa", "ZM": "Zambia", "ZR": "Zaire", "ZW": "Zimbabwe", "ZZ": "Unknown or unspecified country", } languages = { "hi": "Hindi", "en": "English", "ur": "Urdu", "ar": "Arabic", "bn": "Bengali", "kn": "Kannada", "ta": "Tamil", "bg": "Bulgarian", "bn": "Bengali", "ml": "Malayalam", "ru": "Russian", "sr": "Serbian", "uk": "Ukranian", "hr": "Croatian", "ga": "Irish", "sq": "Albanian", "mr": "Marathi", "fa": "Persian", "te": "Telugu", "tr": "Turkish", "hu": "Hungarian", "it": "Italian", "ro": "Romanian", "pa": "Punjabi", "gu": "Gujarati", "or": "Oriya", "zh-CN": "Chinese-Simplified", "zh-TW": "Chinese-Traditional", "ne": "Nepali", "fr": "French", "es": "Spanish", "id": "Indonesian", "el": "Greek", "ja": "Japanese", "jv": "Javanese", "ko": "Korean", "be": "Belarusian", "uz": "Uzbek", "sd": "Sindhi", "af": "Afrikaans", "de": "German", "is": "Icelandic", "ig": "Igbo", "la": "Latin", "pt": "Portugese", "my": "Myanmar", "th": "Thai", "su": "Sundanese", "lo": "Lao", "am": "amharic", "si": "Sinhala", "az": "Azerbaijani", "kk": "Kazakh", "mk": "Macedonian", "bs": "Bosnian", "ps": "Pashto", "mg": "Malagasy", "ms": "Malay", "yo": "Yoruba", "cs": "Czech", "da": "Danish", "nl": "Dutch", "tl": "Tagalog", "no": "Norwegian", "sl": "Slovenian", "sv": " Swedish", "vi": "Vietnamese", "cy": "Welsh", "he": "Hebrew", "hy": "Armenian", "km": "Khmer", "ka": "Georgian", "mn": "Mongolian", "ku": "Kurdish", "ky": "Kyrgyz", "tk": "Turkmen", "fi": "Finnish", "ht": "Haitian Creole", "haw": "Hawaiian", "lt": "Lithuanian", "lb": "Luxembourgish", "mt": "Maltese", "pl": "Polish", "eo": "Esperanto", "tt": "Tatar", "ug": "Uyghur", "ha": "Hausa", "so": "Somali", "sw": "Swahili", "yi": "Yiddish", "eu": "Basque", "ca": "Catalan", "ceb": "Cebuano", "co": "Corsican", "et": "Estonian", "fy": "Frisian", "gl": "Galician", "hmn": "Hmong", "rw": "Kinyarwanda", "lv": "Latvian", "mi": "Maori", "sm": "Samoan", "gd": "Scots Gaelic", "st": "Sesotho", "sn": "Shona", "sk": "Slovak", "xh": "Xhosa", "zu": "Zulu", } ISO_INV = {v: k for k, v in COUNTRY_LIST.items()} ISO_LAN = {v: k for k, v in languages.items()} # CRONJOBS = [ # lpp task deadline cron job # ('*/5 * * * *','conversion.cron.delete_empty_files_existing', '>>'+os.path.join(BASE_DIR,'log/debug7.log')), # translation service down alert # ('2 */6 * * *', 'conversion.cron.check_transalation_services'), # ('2 */6 * * *', 'conversion.cron.delete_trasalation_services'), # # idea mall emails # ("00 16 * * *", "ideamall.cronmails.mailtoauctionwinner"), # ("00 16 * * *", "ideamall.cronmails.mailweekleft"), # ("00 16 * * *", "ideamall.cronmails.mailoneleft"), # # AutoUpdate conversion Rates # ("00 8 * * *", "payment.views.custom_conversion_rate"), # # credits for MM every month # ("00 00 30 * *", "relationshipmanager.views.credit_monthly_outsession"), # # #Institutional Membership # ('0 0 * * *', 'institutional.views.deactivate_expired_accounts'), # ('0 0 1 * *', 'institutional.views.deactivate_accounts_with_pending_payments'), # ('0 0 * * *', 'institutional.views.send_deactivation_reminder_emails'), # # # #auto refund # ('0 1 * * *','subtitling3.cronjob.subtitlerefund'), # # # For reminder mail in messiah # ('*/5 * * * *','relationshipmanager.cron.remindermail'), # ] EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') smtp_host = os.environ.get('SMTP_HOST') smtp_port = int(os.environ.get('SMTP_PORT')) smtp_username = os.environ.get('SMTP_USERNAME') smtp_password = os.environ.get('SMTP_PASSWORD') COUNTRY_KEY = "00000000000000000000000000000000" def discount_xlsx_reader(filePath:str): import pandas as pd discountData = dict() df = pd.read_excel(filePath, engine='openpyxl',skiprows=101) for index, row in df.iterrows(): if not pd.isnull(row['discounts']): if row["limit"] =='yes': discountData[row['discounts']] ={"limit":True, "data":(row['value'],row['start'],row['end'])} else: discountData[row['discounts']] = {"limit":False, "data":row['value']} return discountData DISCOUNT = discount_xlsx_reader(f"{BASE_DIR}/MNF/Pricing.xlsx") def discount_limit_handler(discount:dict) -> int: current_date = datetime.datetime.now() if discount["limit"]: if discount["data"][1].date() <= current_date.date() <= discount["data"][2].date(): return int(discount["data"][0]) else: return int(0) else: return int(discount["data"]) def pricing_data(row_name, column_index): import pandas as pd """ Extract data from a specific cell in an Excel file. Parameters: - row_name (str): The name of the row from which to extract data. - column_index (int): The index of the column from which to extract data. Returns: - str: The data in the format [row][column]. """ try: # Read the Excel file into a DataFrame df = pd.read_excel(file_path) # Find the row index that matches the given row_name row_index = df[df.iloc[:, 0] == row_name].index[0] # Extract the data from the specified cell data = df.iat[row_index, column_index] # Return the data in the format [row][column] return f"{data}" except Exception as e: return f"An error occurred: {e}" #nltk dir changes import nltk nltk.data.path.append("/home/ubuntu/Conversion_Kitchen_Code/nltk_data")