· 5 years ago · Aug 02, 2020, 06:48 PM
1"""
2Django settings for journals_database project.
3Generated by 'django-admin startproject' using Django 3.0.8.
4For more information on this file, see
5https://docs.djangoproject.com/en/3.0/topics/settings/
6For the full list of settings and their values, see
7https://docs.djangoproject.com/en/3.0/ref/settings/
8"""
9
10import os
11import requests
12from background_task import background
13from bs4 import BeautifulSoup
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18# Quick-start development settings - unsuitable for production
19# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
20
21# SECURITY WARNING: keep the secret key used in production secret!
22SECRET_KEY = '4-h)1=jthp1q^w9*rw4@1g^l81h3lvd9&^12!l*i@q-_$hz26k'
23
24# SECURITY WARNING: don't run with debug turned on in production!
25DEBUG = True
26
27ALLOWED_HOSTS = []
28
29# Application definition
30
31INSTALLED_APPS = [
32 'django.contrib.admin',
33 'django.contrib.auth',
34 'django.contrib.contenttypes',
35 'django.contrib.sessions',
36 'django.contrib.messages',
37 'django.contrib.staticfiles',
38 'journals.apps.JournalsConfig',
39 'background_task'
40]
41
42MIDDLEWARE = [
43 'django.middleware.security.SecurityMiddleware',
44 'django.contrib.sessions.middleware.SessionMiddleware',
45 'django.middleware.common.CommonMiddleware',
46 'django.middleware.csrf.CsrfViewMiddleware',
47 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 'django.contrib.messages.middleware.MessageMiddleware',
49 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50]
51
52ROOT_URLCONF = 'journals_database.urls'
53
54TEMPLATES = [
55 {
56 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57 'DIRS': [os.path.join(BASE_DIR, 'templates')]
58 ,
59 'APP_DIRS': True,
60 'OPTIONS': {
61 'context_processors': [
62 'django.template.context_processors.debug',
63 'django.template.context_processors.request',
64 'django.contrib.auth.context_processors.auth',
65 'django.contrib.messages.context_processors.messages',
66 ],
67 },
68 },
69]
70
71WSGI_APPLICATION = 'journals_database.wsgi.application'
72
73# Database
74# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
75
76DATABASES = {
77 'default': {
78 'ENGINE': 'django.db.backends.sqlite3',
79 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
80 }
81}
82
83# Password validation
84# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
85
86AUTH_PASSWORD_VALIDATORS = [
87 {
88 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
89 },
90 {
91 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
92 },
93 {
94 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
95 },
96 {
97 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
98 },
99]
100
101# Internationalization
102# https://docs.djangoproject.com/en/3.0/topics/i18n/
103
104LANGUAGE_CODE = 'en-us'
105
106TIME_ZONE = 'UTC'
107
108USE_I18N = True
109
110USE_L10N = True
111
112USE_TZ = True
113
114# Static files (CSS, JavaScript, Images)
115# https://docs.djangoproject.com/en/3.0/howto/static-files/
116
117STATIC_URL = '/static/'
118
119MINISTERIAL_HTTPS = 'https://www.bip.nauka.gov.pl/wykaz-czasopism-naukowych/'
120
121
122@background(schedule=10)
123def getExcel():
124 ministerial_request = requests.get(MINISTERIAL_HTTPS)
125 ministerial_soup = BeautifulSoup(ministerial_request.text, 'html.parser')
126 latest_entry = ministerial_soup.find('ul', {'class': 'list-news'}).findChildren('a')[0]
127 print(latest_entry)