Skip to content

Commit

Permalink
Added custom styles
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristineKarimi committed May 28, 2018
1 parent c6f8798 commit f59d0c9
Show file tree
Hide file tree
Showing 554 changed files with 49,734 additions and 19,322 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn carpool.wsgi
Binary file modified carpool/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified carpool/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file modified carpool/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file removed carpool/__pycache__/views.cpython-36.pyc
Binary file not shown.
Binary file modified carpool/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
48 changes: 48 additions & 0 deletions carpool/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth.models import User
from django.utils.deprecation import MiddlewareMixin

ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15)
ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50)


def get_online_now(self):
return User.objects.filter(id__in=self.online_now_ids or [])


class OnlineNowMiddleware(MiddlewareMixin):
"""
Maintains a list of users who have interacted with the website recently.
Their user IDs are available as ``online_now_ids`` on the request object,
and their corresponding users are available (lazily) as the
``online_now`` property on the request object.
"""

def process_request(self, request):
# First get the index
uids = cache.get('online-now', [])

# Perform the multiget on the individual online uid keys
online_keys = ['online-%s' % (u,) for u in uids]
fresh = cache.get_many(online_keys).keys()
online_now_ids = [int(k.replace('online-', '')) for k in fresh]

# If the user is authenticated, add their id to the list
if request.user.is_authenticated():
uid = request.user.id
# If their uid is already in the list, we want to bump it
# to the top, so we remove the earlier entry.
if uid in online_now_ids:
online_now_ids.remove(uid)
online_now_ids.append(uid)
if len(online_now_ids) > ONLINE_MAX:
del online_now_ids[0]

# Attach our modifications to the request object
request.__class__.online_now_ids = online_now_ids
request.__class__.online_now = property(get_online_now)

# Set the new cache
cache.set('online-%s' % (request.user.pk,), True, ONLINE_THRESHOLD)
cache.set('online-now', online_now_ids, ONLINE_THRESHOLD)
38 changes: 35 additions & 3 deletions carpool/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,33 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=True, cast=bool)
# SECRET_KEY = config('SECRET_KEY')
CLIENT_ID = ('CLIENT_ID')
# API_KEY = config('API_KEY')
GOOGLE_API = 'AIzaSyAjT5RSv8RGaxktrIJYOLLPmU-SwjqnGvk'
GEOPOSITION_GOOGLE_MAPS_API_KEY = 'AIzaSyAjT5RSv8RGaxktrIJYOLLPmU-SwjqnGvk'


LOCATION_FIELD = {
'map.provider': 'google',
'map.zoom': 15,
'search.provider': 'google',
'provider.google.api': '//maps.google.com/maps/api/js?sensor=false',
'provider.google.api_key': GOOGLE_API,
'provider.google.map.type': 'ROADMAP',
}

GEOPOSITION_MAP_OPTIONS = {
'minZoom': 3,
'maxZoom': 15,
}

GEOPOSITION_MARKER_OPTIONS = {
'cursor': 'move'
}

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']

Expand All @@ -42,8 +68,11 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap3',
'drivers',
'passenger',
'driver',
'rider',
'geoposition',
# 'cart',

]

MIDDLEWARE = [
Expand Down Expand Up @@ -78,6 +107,9 @@
]

WSGI_APPLICATION = 'carpool.wsgi.application'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = '/media/'



# Database
Expand Down Expand Up @@ -140,4 +172,4 @@
os.path.join(BASE_DIR, "static"),
]

# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
Loading

0 comments on commit f59d0c9

Please sign in to comment.