Skip to content

Commit

Permalink
Merge pull request #263 from unicef/staging
Browse files Browse the repository at this point in the history
staging-step2
  • Loading branch information
robertavram committed Nov 18, 2016
2 parents 8c99721 + 51c5504 commit 3282b66
Show file tree
Hide file tree
Showing 27 changed files with 720 additions and 154 deletions.
3 changes: 0 additions & 3 deletions EquiTrack/EquiTrack/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@

{'app': 'locations', 'icon': 'icon-map-marker'},

#{'app': 'filer', 'label': 'Files', 'icon': 'icon-file'},

{'app': 'tpm', 'label': 'TPM Portal', 'icon': 'icon-calendar'},
)
}
Expand Down Expand Up @@ -374,7 +372,6 @@
'mathfilters',

'easy_thumbnails',
'filer',
'storages',
'rest_framework',
'rest_framework_swagger',
Expand Down
6 changes: 3 additions & 3 deletions EquiTrack/EquiTrack/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
INTERNAL_IPS = ('127.0.0.1',)

# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
# MIDDLEWARE_CLASSES += (
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
# )
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
DEBUG_TOOLBAR_CONFIG = {
Expand Down
1 change: 0 additions & 1 deletion EquiTrack/EquiTrack/settings/local_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True
FILER_DEBUG = DEBUG

ALLOWED_HOSTS = ['127.0.0.1']

Expand Down
26 changes: 10 additions & 16 deletions EquiTrack/EquiTrack/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,6 @@
# MEDIA_URL = 'https://{}.blob.core.windows.net/{}/'.format(
# AZURE_ACCOUNT_NAME, AZURE_CONTAINER
# )
FILER_IS_PUBLIC_DEFAULT = False
FILER_STORAGES = {
'public': {
'main': {
'ENGINE': 'storages.backends.azure_storage.AzureStorage',
'UPLOAD_TO': 'partners.utils.by_pca',
},
},
'private': {
'main': {
'ENGINE': 'storages.backends.azure_storage.AzureStorage',
'UPLOAD_TO': 'partners.utils.by_pca',
},
},
}

from storages.backends.azure_storage import AzureStorage
storage = AzureStorage()
Expand Down Expand Up @@ -218,4 +203,13 @@

'JWT_AUTH_HEADER_PREFIX': 'JWT',
}
######## END JWT AUTH CONFIGURATION
######## END JWT AUTH CONFIGURATION

########## CACHE CONFIGURATION
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': environ.get('REDIS_URL', 'redis://localhost:6379/0')
}
}
########## END CACHE CONFIGURATION
6 changes: 5 additions & 1 deletion EquiTrack/EquiTrack/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# import every app/autocomplete_light_registry.py
autocomplete_light.autodiscover()

from rest_framework_swagger.views import get_swagger_view

from rest_framework_nested import routers

# Uncomment the next two lines to enable the admin:
Expand Down Expand Up @@ -71,6 +73,8 @@
LabelViewSet,
)

schema_view = get_swagger_view(title='eTools API')

api = routers.SimpleRouter()

trips_api = routers.SimpleRouter()
Expand Down Expand Up @@ -147,7 +151,7 @@
url(r'^api/', include(trips_api.urls)),
url(r'^api/', include(tripsfiles_api.urls)),
url(r'^api/', include(actionpoint_api.urls)),
url(r'^api/docs/', include('rest_framework_swagger.urls')),
url(r'^api/docs/', schema_view),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
Expand Down
20 changes: 20 additions & 0 deletions EquiTrack/activityinfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@


class Database(models.Model):
"""
Represents ActivityInfo database client.
Can import database data and reports data from ActivityInfoClient.
"""

ai_id = models.PositiveIntegerField(
unique=True,
Expand Down Expand Up @@ -157,6 +162,9 @@ def import_reports(self):


class Partner(models.Model):
"""
Represents Partner in ActivityInfo database client.
"""

ai_id = models.PositiveIntegerField(unique=True)
database = models.ForeignKey(Database)
Expand All @@ -171,6 +179,9 @@ def __unicode__(self):


class Activity(models.Model):
"""
Represents Activity in ActivityInfo database client.
"""

ai_id = models.PositiveIntegerField(unique=True)
database = models.ForeignKey(Database)
Expand All @@ -185,6 +196,9 @@ class Meta:


class Indicator(models.Model):
"""
Represents Indicator in ActivityInfo database client.
"""

ai_id = models.PositiveIntegerField(unique=True)
activity = models.ForeignKey(Activity)
Expand All @@ -197,6 +211,9 @@ def __unicode__(self):


class AttributeGroup(models.Model):
"""
Represents AttributeGroup in ActivityInfo database client.
"""

activity = models.ForeignKey(Activity)
ai_id = models.PositiveIntegerField(unique=True)
Expand All @@ -209,6 +226,9 @@ def __unicode__(self):


class Attribute(models.Model):
"""
Represents Attribute in ActivityInfo database client.
"""

attribute_group = models.ForeignKey(AttributeGroup)
ai_id = models.PositiveIntegerField(unique=True)
Expand Down
15 changes: 9 additions & 6 deletions EquiTrack/funds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


class Donor(models.Model):
"""
Represents Donor for a Grant.
"""

name = models.CharField(max_length=45L, unique=True)

class Meta:
Expand All @@ -13,17 +17,16 @@ def __unicode__(self):
return self.name


class GrantManager(models.Manager):

def get_queryset(self):
return super(GrantManager, self).get_queryset().select_related('donor')


class GrantManager(models.Manager):
def get_queryset(self):
return super(GrantManager, self).get_queryset().select_related('donor')

class Grant(models.Model):
"""
Represents the name of a Grant with expiration date, and Donor name.
Relates to :model:`funds.Donor`
"""

donor = models.ForeignKey(Donor)
name = models.CharField(max_length=128L, unique=True)
Expand Down
43 changes: 42 additions & 1 deletion EquiTrack/locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def get_random_color():


class GatewayType(models.Model):
"""
Represents an Admin Type in location-related models.
"""

name = models.CharField(max_length=64L, unique=True)

class Meta:
Expand All @@ -36,6 +40,12 @@ def __unicode__(self):


class Governorate(models.Model):
"""
Represents Admin level as a geospatial boundary
Relates to :model:`locations.GatewayType`
"""

name = models.CharField(max_length=45L)
p_code = models.CharField(max_length=32L, blank=True, null=True)
gateway = models.ForeignKey(
Expand All @@ -56,6 +66,13 @@ class Meta:


class Region(models.Model):
"""
Represents a district, a part of Admin area as a geospatial boundary
Relates to :model:`locations.GatewayType`
Relates to :model:`locations.Governorate`
"""

governorate = models.ForeignKey(Governorate)
name = models.CharField(max_length=45L)
p_code = models.CharField(max_length=32L, blank=True, null=True)
Expand All @@ -78,6 +95,13 @@ class Meta:


class Locality(models.Model):
"""
Represents Locality, a part of District area as a geospatial boundary
Relates to :model:`locations.GatewayType`
Relates to :model:`locations.Region`
"""

region = models.ForeignKey(Region)
cad_code = models.CharField(max_length=11L)
cas_code = models.CharField(max_length=11L)
Expand Down Expand Up @@ -111,6 +135,13 @@ def get_queryset(self):


class Location(MPTTModel):
"""
Represents Location, either a point or geospatial ojject,
pcode should be unique
Relates to :model:`locations.GatewayType`
Relates to :model:`locations.Locality`
"""

name = models.CharField(max_length=254L)
locality = models.ForeignKey(Locality, null=True, blank=True)
Expand Down Expand Up @@ -166,7 +197,12 @@ def invalidate_locations_etag(sender, instance, **kwargs):

class LinkedLocation(models.Model):
"""
Generic model for linking locations to anything
Represents Generic model for linking locations to anything
Relates to :model:`locations.Governorate`
Relates to :model:`locations.Region`
Relates to :model:`locations.Locality`
Relates to :model:`locations.Location`
"""
governorate = models.ForeignKey(Governorate)
region = ChainedForeignKey(
Expand Down Expand Up @@ -217,6 +253,11 @@ def __unicode__(self):


class CartoDBTable(MPTTModel):
"""
Represents a table in CartoDB, it is used to import lacations
Relates to :model:`locations.GatewayType`
"""

domain = models.CharField(max_length=254)
api_key = models.CharField(max_length=254)
Expand Down
2 changes: 1 addition & 1 deletion EquiTrack/locations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GatewayTypeSerializer(serializers.ModelSerializer):

class Meta:
model = GatewayType

fields = '__all__'

class LocationSerializer(serializers.ModelSerializer):

Expand Down
Loading

0 comments on commit 3282b66

Please sign in to comment.