Skip to content

Commit

Permalink
Merge pull request #158 from uw-it-aca/qa
Browse files Browse the repository at this point in the history
Qa
  • Loading branch information
devights authored Sep 23, 2016
2 parents 434906d + 9f6ac4b commit 7276878
Show file tree
Hide file tree
Showing 154 changed files with 13,261 additions and 1,756 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = scout
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.DS_Store

# devights added other ignores
.idea
project/*
manage.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -67,4 +72,7 @@ static/CACHE
*.sqlite3

#sass cache
*.sass-cache
*.sass-cache

# node
node_modules/
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sudo: false
language: python
python:
- "2.7.6"
install:
- python setup.py -q install
before_script:
- pip install coverage
- pip install python-coveralls
- pip install pep8
- pip install -r requirements.txt
- cp travis-ci/manage.py manage.py
- python manage.py migrate --noinput
- npm install mocha
- npm install jquery
- npm install jsdom@3
script:
- pep8 scout/ --exclude=migrations
- coverage run --source=scout/ --omit=scout/migrations/* manage.py test scout
- mocha scout/static/scout/js/test --recursive
after_script:
- coveralls
notifications:
webhooks:
urls:
- https://yarn.cac.washington.edu/rest/botalyst/v1/travis-ci
slack:
secure: QhQcPJdxvdl5GlPdiewvyMMzDAM5fFB0Db2kRwpDphn8KiyNv2cF1SVeiYaJcQ4fObA7eWgsBXGBd/be8OC/1ujGNncz92bJM5xHePzMxs37hjPFaHuDGH0pnqurQIhRTz6OoWDi2+2OzC3xP1VkpOv0/2ApFjhUkO8S6JodH9A=
92 changes: 68 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Build Status](https://travis-ci.org/uw-it-aca/scout.svg?branch=develop)](https://travis-ci.org/uw-it-aca/scout) [![Coverage Status](https://coveralls.io/repos/uw-it-aca/scout/badge.svg?branch=master&service=github)](https://coveralls.io/github/uw-it-aca/scout?branch=master)
SCOUT
=====

Expand All @@ -9,37 +10,80 @@ The Scout project uses Vagrant and Ansible to build your development environment

https://github.com/uw-it-aca/scout-vagrant


## API ##

Refer to the Spotseeker API https://github.com/uw-it-aca/spotseeker_server/wiki/REST-protocol-v1
Refer to the Spotseeker API https://github.com/uw-it-aca/spotseeker_server/wiki/REST-protocol-v1 to view documentation regarding core data that is needed for all spots.


The following types are to be used for Food finding...

"type": ["cafe", "cafeteria", "market", "restaurant", "food_truck"],
"type" : ["cafe", "cafeteria", "food_court", "food_truck" "market", "restaurant"],

Scout specific extended info...

This meta type is needed...
"extended_info": {

"meta_type": ["food"],
// global

General extended info...

"extended_info": {
"campus","seattle"
"hours_notes", ""
"access_notes", ""
},

Scout specific extended info...

"extended_info": {
“cuisine” : [“american”, “bbq”, "chinese", "hawaiian", "itallian"],
“food_served” : [“burgers”, “salads”, “appetizers”, “pizza”, "sandwiches", "coffee_espresso"],
“menu_url” : “”,
“website_url” : “”,
“has_delivery” : true,
“payment_accepted” : [“cash”, “visa”, “mastercard”, “husky_card”, “dining_account”],
“open_period” : [“breakfast”, “lunch”, “dinner”, “late_night”],
},
"app_type" : ["food", "study", "other"],
"campus" : "seattle", ( or bothell, tacoma, south_lake_union)
"hours_notes" : "",
"access_notes" : "",

// scout

"s_menu_url" : "",
"s_website_url" : "",
"s_phone" : "",
"s_email" : "",

"s_has_alert" : false,
"s_alert_notes" : "",

"s_has_reservation" : false,
"s_reservation_notes" : "",

"s_has_coupon" : "true",
"s_coupon_expiration" : "datetime",
"s_coupon_url" : "",

// cuisine

"s_cuisine_american" : true,
"s_cuisine_bbq" : false,
"s_cuisine_chinese" : false,
"s_cuisine_hawaiian" : false,
"s_cuisine_indian" : false,
"s_cuisine_italian" : false,
"s_cuisine_korean" : false,
"s_cuisine_mexican" : false,
"s_cuisine_vietnamese" : false,

// food served

"s_food_breakfast" : true,
"s_food_burgers" : true,
"s_food_curry" : true,
"s_food_desserts" : true,
"s_food_entrees" : true,
"s_food_espresso" : true,
"s_food_frozen_yogurt" : true,
"s_food_pasta" : true,
"s_food_pastries" : true,
"s_food_pho" : true,
"s_food_pizza" : true,
"s_food_salads" : true,
"s_food_sandwiches" : true,
"s_food_smoothies" : true,
"s_food_sushi_packaged" : true,
"s_food_tacos" : true,

// payment extended info

"s_pay_cash" : true,
"s_pay_visa" : true,
"s_pay_mastercard" : true,
"s_pay_husky" : true,
"s_pay_dining" : true,
},
8 changes: 1 addition & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
django
django-compressor
django_mobileesp
django-turbolinks
django-htmlmin
libsass

-e git+https://github.com/uw-it-aca/spotseeker_client.git#egg=spotseeker-restclient
-e .
3 changes: 3 additions & 0 deletions requirements_saucelabs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sauceclient
selenium
pyvirtualdisplay
28 changes: 20 additions & 8 deletions scout/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from django.conf import settings


def google_maps(request):
""" See if there is a Google Analytics web property id
"""
gmaps_api_key = getattr(settings, 'GOOGLE_MAPS_API', False)
return {
'GOOGLE_MAPS_API': gmaps_api_key,
'google_maps': gmaps_api_key
}


def google_analytics(request):

ga_key = getattr(settings, 'GOOGLE_ANALYTICS_KEY', False)
Expand All @@ -8,19 +19,20 @@ def google_analytics(request):
'google_analytics': ga_key
}


def is_desktop(request):

desktopapp = not request.is_mobile and not request.is_tablet

return {
'is_desktop' : desktopapp
'is_desktop': desktopapp
}



def is_hybrid(request):

hybridapp = request.GET.get('hybrid')

return {
'is_hybrid' : hybridapp
'is_hybrid': hybridapp
}

Empty file added scout/dao/__init__.py
Empty file.
35 changes: 35 additions & 0 deletions scout/dao/image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.conf import settings
from spotseeker_restclient.spotseeker import Spotseeker
from spotseeker_restclient.exceptions import DataFailureException
import oauth2


def get_client():
# Required settings for the client
if not hasattr(settings, 'SPOTSEEKER_HOST'):
raise(Exception("Required setting missing: SPOTSEEKER_HOST"))
if not hasattr(settings, 'SPOTSEEKER_OAUTH_KEY'):
raise(Exception("Required setting missing: SPOTSEEKER_OAUTH_KEY"))
if not hasattr(settings, 'SPOTSEEKER_OAUTH_SECRET'):
raise(Exception("Required setting missing: SPOTSEEKER_OAUTH_SECRET"))

consumer = oauth2.Consumer(key=settings.SPOTSEEKER_OAUTH_KEY,
secret=settings.SPOTSEEKER_OAUTH_SECRET)
client = oauth2.Client(consumer)

return client


def get_image(spot_id, image_id, width=None):
client = get_client()
if width is not None:
url = "%s/api/v1/spot/%s/image/%s/thumb/constrain/width:%s" % (
settings.SPOTSEEKER_HOST,
spot_id,
image_id,
width)
else:
url = "%s/api/v1/spot/%s/image/%s" % (settings.SPOTSEEKER_HOST,
spot_id,
image_id)
return client.request(url, 'GET')
104 changes: 104 additions & 0 deletions scout/dao/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from scout.dao.space import get_spots_by_filter, _get_spot_filters, \
_get_extended_info_by_key
import copy


def get_item_by_id(item_id):
spot = get_spots_by_filter([
('item:id', item_id),
('extended_info:app_type', 'tech')
])
if spot:
spot = _filter_spot_items(item_id, spot[0])
return spot


def _filter_spot_items(item_id, spot):
for item in spot.items:
if item.item_id == item_id:
spot.item = item
return spot


def add_item_info(spot):
for item in spot.items:
item.model = _get_extended_info_by_key("i_model",
item.extended_info)
item.brand = _get_extended_info_by_key("i_brand",
item.extended_info)
item.checkout_period = _get_extended_info_by_key(
"i_checkout_period",
item.extended_info
)
item.has_access_restriction = _get_extended_info_by_key(
"i_has_access_restriction",
item.extended_info
)
item.access_limit_role = _get_extended_info_by_key(
"i_access_limit_role",
item.extended_info
)
item.access_role_students = _get_extended_info_by_key(
"i_access_role_students",
item.extended_info
)
item.reservation_required = _get_extended_info_by_key(
"i_reservation_required",
item.extended_info
)
item.is_active = _get_extended_info_by_key(
"i_is_active",
item.extended_info
)
item.quantity = _get_extended_info_by_key(
"i_quantity",
item.extended_info
)
item.description = _get_extended_info_by_key(
"i_description",
item.extended_info
)
item.reserve_url = _get_extended_info_by_key(
"i_reserve_url",
item.extended_info
)
item.manual_url = _get_extended_info_by_key(
"i_manual_url",
item.extended_info
)
return spot


def get_filtered_items(spots, request):
parameter_list = _get_spot_filters(request)
brand = []
subcategory = []
for param in parameter_list:
if param[0] == "item:extended_info:i_brand":
brand.append(param[1])
elif param[0] == "item:subcategory":
subcategory.append(param[1])

if len(brand) <= 0 and len(subcategory) <= 0:
return spots

newSpots = []

for spot in spots:
newSpot = copy.deepcopy(spot)
newSpot.items = []
for item in spot.items:
if item.subcategory in subcategory:
newSpot.items.append(item)
else:
if item.brand in brand:
newSpot.items.append(item)
newSpots.append(newSpot)
return newSpots


def get_item_count(spots):
item_count = 0
for spot in spots:
item_count += len(spot.items)
return item_count
Loading

0 comments on commit 7276878

Please sign in to comment.