Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
faizanfareed committed Jul 5, 2020
0 parents commit 40677b5
Show file tree
Hide file tree
Showing 63 changed files with 4,026 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
manage.py
env/
covid19/
media/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2020] [Muhammad Faizan Fareed]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added covid19nearyou/__init__.py
Empty file.
Binary file added covid19nearyou/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/apps.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added covid19nearyou/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added covid19nearyou/__pycache__/redis_keys.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/signals.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added covid19nearyou/__pycache__/views.cpython-36.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions covid19nearyou/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.contrib import admin
from .models import *


admin.site.register(ConfirmedCaseLocation,ConfirmedCaseLocationAdmin)

admin.site.register(QurantineCenter,QurantineCenterAdmin)

admin.site.register(GeospatialFile,GeospatialFileAdmin)

admin.site.register(RedisBatchManager,RedisBatchManagerAdmin)

admin.site.register(ConfirmedCaseLocationBatch,ConfirmedCaseLocationBatchAdmin)

admin.site.register(QuarantineCenterBatch,QuarantineCenterBatchAdmin)


26 changes: 26 additions & 0 deletions covid19nearyou/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.apps import AppConfig
from django.contrib.admin.apps import AdminConfig
from django.contrib.admin import AdminSite
from django.contrib import admin


class Covid19NearyouConfig(AppConfig):
name = 'covid19nearyou'


def ready(self):
from . import receivers



class MyAdminConfig(AdminConfig):
default_site = 'covid19nearyou.apps.MyAdminSite'


class MyAdminSite(admin.AdminSite):

site_header = 'COVID-19 NEAR YOU ADMINISTRATION'
site_title = 'COVID-19 NEAR YOU ADMIN'

index_title = 'COVID-19 NEAR YOU MODELS'
admin.empty_value_display = '**Empty**'
10 changes: 10 additions & 0 deletions covid19nearyou/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.conf import settings # import the settings file

def setting_constants(request):
# return the value you want as a dictionnary.
instance = settings.__dict__['_wrapped'].__dict__
return instance




72 changes: 72 additions & 0 deletions covid19nearyou/covid19_settings_variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

#Batch size
LOCATION_CACHE_BATCH_SIZE = 50


#Region incuabation peroid.
# See Incubation peroid time of COVID-19 on World Health Organization website
COVID19_INCUBATION_PERIOD_FOR_EXPIRE_POINT = 6 # days

#Geospatial file update time
COVID19_UPDATE_DATA_TIME = 12 # Hours


#Different radius ranges for finding points
FIRST_RANGE_CIRCLE = 1 # 1st range/zone
SECOND_RANGE_CIRCLE = 2 # 2nd radius range/zone
THIRD_RANGE_CIRCLE = 3 # 3rd radius range/zone

# The radius is specified in one of the following units:
# m for meters.
# km for kilometers.
# mi for miles.
# ft for feet.

# Radius range unit
RANGE_IN_UNITS = 'km'






#Don't need to change these. These are used for Map
FIRST_RANGE_CIRCLE_RADIUS = FIRST_RANGE_CIRCLE * 1000
SECOND_RANGE_CIRCLE_RADIUS = SECOND_RANGE_CIRCLE * 1000
THIRD_RANGE_CIRCLE_RADIUS = THIRD_RANGE_CIRCLE * 1000


# Quarantine radius range
QUARANTINE_RADIUS_RANGE = 10 # Km
QUARANTINE_RADIUS_RANGE_UNIT = 'km'


#Pakistan Map canter point
#Change these according to your country

MAP_CENTER_POINT_LATITUDE = 31.433254
MAP_CENTER_POINT_MAGNITUDE = 74.350311



#By Default Pakistan boundry (polygon)
#Change these according to your country

REGION_BOUNDRY_MIN_LATITUDE = 23
REGION_BOUNDRY_MAX_LATITUDE = 37

REGION_BOUNDRY_MIN_LONGITUDE = 60
REGION_BOUNDRY_MAX_LONGITUDE = 77


#No need to change
WHO_WEBSITE_LINK_NAME = 'WHO advice'
WHO_WEBSITE_LINK = 'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/advice-for-public'

#By default Pakistan
#Change these according to your country
MY_COUNTRY_COVID19_WEB_LINK_NAME = 'PAKISTAN COVID-19'
MY_COUNTRY_COVID19_WEB_LINK = 'http://covid.gov.pk/'

#Country name
COUNTRY_NAME = 'PAKISTAN'
71 changes: 71 additions & 0 deletions covid19nearyou/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from . models import *

from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _

from django.conf import settings





class LatitudeLongitudeForm(forms.Form):

latitude = forms.FloatField(help_text='Latitude ',localize=True,widget= forms.TextInput
(attrs={'placeholder':'Latitude'}))

longitude = forms.FloatField(help_text=' Longitude',localize=True, widget= forms.TextInput
(attrs={'placeholder':'Longitude'}))


def clean_latitude(self):

if isinstance(self.cleaned_data['latitude'],(float)):

Latitude = float(self.cleaned_data['latitude'])

if Latitude < settings.REGION_BOUNDRY_MIN_LATITUDE or Latitude >= settings.REGION_BOUNDRY_MAX_LATITUDE :
raise forms.ValidationError(
_(' Latitude out of range'),code='outofrange'

)



return Latitude

def clean_longitude(self):

if isinstance(self.cleaned_data['longitude'],(float)):

Longitude = float(self.cleaned_data['longitude'])



if Longitude < settings.REGION_BOUNDRY_MIN_LONGITUDE or Longitude >= settings.REGION_BOUNDRY_MAX_LONGITUDE :
raise forms.ValidationError(
_('Longitude out of range'),code='outofrange',

)



return Longitude

class GeospatialFileForm(forms.ModelForm):

class Meta:
model = GeospatialFile
exclude = ('created_at','is_finshed','finshed_at',)


class LocationBatchManagerForm(forms.ModelForm):


class Meta:
model = RedisBatchManager
exclude = ( 'created_at','is_finshed','is_quarantine_batches_completed','is_location_batches_completed','location_batches','qurantine_batches','location_points','qurantine_points','location_completed_batches','qurantine_completed_batches',)



100 changes: 100 additions & 0 deletions covid19nearyou/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Generated by Django 3.0.7 on 2020-06-29 10:58

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='ConfirmedCaseLocation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('expire_at', models.DateTimeField()),
('is_visible', models.BooleanField(default=True)),
('latitude', models.DecimalField(decimal_places=6, max_digits=8)),
('longitude', models.DecimalField(decimal_places=6, max_digits=8)),
],
),
migrations.CreateModel(
name='GeospatialFile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('is_finshed', models.BooleanField(default=False)),
('finshed_at', models.DateTimeField(null=True)),
],
),
migrations.CreateModel(
name='QurantineCenter',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_visible', models.BooleanField(default=True)),
('latitude', models.DecimalField(decimal_places=6, max_digits=8)),
('longitude', models.DecimalField(decimal_places=6, max_digits=8)),
],
),
migrations.CreateModel(
name='RedisBatchManager',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('is_finshed', models.BooleanField(default=False)),
('is_quarantine_batches_completed', models.BooleanField(default=False)),
('is_location_batches_completed', models.BooleanField(default=False)),
('location_points', models.PositiveIntegerField(blank=True, default=0)),
('qurantine_points', models.PositiveIntegerField(blank=True, default=0)),
('location_batches', models.PositiveIntegerField(blank=True, default=0)),
('qurantine_batches', models.PositiveIntegerField(blank=True, default=0)),
('location_completed_batches', models.PositiveIntegerField(blank=True, default=0)),
('qurantine_completed_batches', models.PositiveIntegerField(blank=True, default=0)),
],
),
migrations.CreateModel(
name='QuarantineCenterBatch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('is_completed', models.BooleanField(default=False)),
('batch_no', models.PositiveIntegerField()),
('range_start', models.PositiveIntegerField()),
('range_end', models.PositiveIntegerField()),
('batch_manager', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='covid19nearyou.RedisBatchManager')),
],
),
migrations.CreateModel(
name='ConfirmedCaseLocationBatch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('is_completed', models.BooleanField(default=False)),
('batch_no', models.PositiveIntegerField()),
('range_start', models.PositiveIntegerField()),
('range_end', models.PositiveIntegerField()),
('batch_manager', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='covid19nearyou.RedisBatchManager')),
],
),
migrations.CreateModel(
name='AddToFileNewAndExpireOldCovid19Location',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_file_created', models.BooleanField(default=False)),
('is_points_removed', models.BooleanField(default=False)),
('is_finshed', models.BooleanField(default=False)),
('url', models.URLField(null=True)),
('geospatialfile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='covid19nearyou.GeospatialFile')),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 40677b5

Please sign in to comment.