COVID-19 NEAR YOU

Find confirmed cases in 1,2 and 3 km and quarantine center in 10 Km radius range based on user given location, give some useful advises and informational links, and help officials to control covid19 transmission.

If people already know about infected regions and people of these regions transmitting the virus,then they will avoid them, (infected regions and thier people as well) so they will be definitely taking necessary precautions.

Must Read How COVID-19 NEAR YOU app can help to control transmission ?


forthebadge made-with-python

Generic badge Generic badge

Open Source Love svg3

Table of contents

Note : Leaflet auto navigation not giving precise location of user that’s why we are getting user precise location manually.

Requirements

Virtual environment

Create new directory

mkdir covid19

Change directory

cd covid19/

Create virtual environment

python3 -m venv env

Activate virtual environment

# Windows:
env\Scripts\activate.bat

# On Unix or MacOS, run:
source env/bin/activate

Installation

Clone repository

git clone git@github.com:FaizanFareed/COVID-19-NEAR-YOU.git

Change directory

cd COVID-19-NEAR-YOU/

Create media directory

mkdir -p media/location

Install all dependencies

pip install -r requirements.txt

Create new project with name covid19.

# Don't forget to miss "." .
django-admin startproject covid19 . 

Setup

Add MySQL database config into covid19/settings.py. And delete by default SQLite database directive (config).

# covid19/settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': config('DB_NAME'),
        'USER': config('DB_USER'),
        'PASSWORD': config('DB_PASSWORD'),
        'HOST': config('DB_HOST'),
        'PORT': config('DB_PORT'),
    }
}

Add Email provider config into covid19/settings.py

# covid19/settings.py

# Console backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Email provider
#DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL')
#EMAIL_BACKEND = config('EMAIL_BACKEND')
#EMAIL_HOST = config('EMAIL_HOST')
#EMAIL_USE_TLS = config('EMAIL_USE_TLS',cast=bool)
#EMAIL_PORT = config('EMAIL_PORT',cast=int)
#EMAIL_HOST_USER = config('EMAIL_HOST_USER')
#EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')

Add Redis config into covid19/settings.py

# covid19/settings.py

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": config('REDIS_LOCATION_URL'), # Redis url
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "IGNORE_EXCEPTIONS": True,
            "REDIS_CLIENT_KWARGS": {"decode_responses": True, 'charset':"utf-8"},
        }
    },"KEY_PREFIX" : "covid19",
}

# Storing session in Redis
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
DJANGO_REDIS_IGNORE_EXCEPTIONS = True

Copy this and paste into covid19/urls.py

# covid19/urls.py

from django.urls import include
from django.contrib.auth import views as auth_views

urlpatterns = [
    ... # Others if any 

    # Admin password reset urls
    path('admin/password_reset/',auth_views.PasswordResetView.as_view(),name='admin_password_reset',),
    path('admin/password_reset/done/',auth_views.PasswordResetDoneView.as_view(),name='password_reset_done',),
    path('reset/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(),name='password_reset_confirm',),
    path('reset/done/',auth_views.PasswordResetCompleteView.as_view(),name='password_reset_complete',),
    path('admin/', include('django.contrib.auth.urls')),

    # covid19nearyou app urls
    path('',include('covid19nearyou.urls'))
]

Copy this and paste into covid19/settings.py

# covid19/settings.py

#Static and media urls and root directory 

# Static files 
STATIC_URL = '/files/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),]

# Media files
MEDIA_ROOT = BASE_DIR + '/media/'
MEDIA_URL = '/location-points/'

Change your time zone from covid19/settings.py.

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Karachi' # your timezone

Add setting_constants context processer and template path into TEMPLATES directive in covid19/settings.py

# covid19/settings.py

TEMPLATES = [
        {
            ... # others 
            'DIRS': [os.path.join(BASE_DIR, 'templates')], # copy this  
            'OPTIONS': {
                ... # others
                'context_processors': [
                    ... # others
                    'covid19nearyou.context_processors.setting_constants', # copy this 
                ],
            },
        },
    ]

Copy these and paste into covid19/urls.py

# covid19/urls.py

from django.conf import settings
from django.conf.urls.static import static

Add static and media path

# covid19/urls.py

urlpatterns = [
        ... # urls
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # copy and add this at the end of urlpatterns 

urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # copy this 

Add covid19nearyou app and MyAdminConfig into INSTALLED_APPS directive in covid19/settings.py

# covid19/settings.py

INSTALLED_APPS = [
    ... # others apps 
    'covid19nearyou.apps.Covid19NearyouConfig',
    'covid19nearyou.apps.MyAdminConfig',
]

Copy all directives from covid19_settings_variables and paste into covid19/settings.py. And change these directives according to your requirements.

# covid19/settings.py

... # others directives 

LOCATION_CACHE_BATCH_SIZE = 100
...
# All directives of covid19_settings_variables.py file goes here

Change country name in covid19/settings.py

COUNTRY_NAME = 'PAKISTAN' # your country name  

Migrate

python manage.py  migrate

Create superuser

python manage.py createsuperuser

username : #enter username
Email address: # enter your emailaddress
Password: #enter your password
Password (again): # again enter your password

Run server

python manage.py runserver

App links

FAQ

License

Generic badge

License under a MIT License.

Contributing

If you have any suggestions , request new features ,found bugs, or you can start discussion at https://github.com/FaizanFareed/COVID-19-NEAR-YOU/issues

Built with

Open source software used in this project

Open soruce software license