Skip to content

Commit

Permalink
Merge pull request #8 from andela-snwuguru/ch-ci-integration-124769321
Browse files Browse the repository at this point in the history
#124769321 CI Integration
  • Loading branch information
Nwuguru Sunday committed Jul 15, 2016
2 parents 4c11231 + 1bc32cd commit 43eeb80
Show file tree
Hide file tree
Showing 18 changed files with 303 additions and 74 deletions.
1 change: 1 addition & 0 deletions .coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/__init__.py": [1], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/views.py": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 18, 20, 21, 22, 24, 27, 60], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/urls.py": [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/image_edit.py": [1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 27, 31, 32, 34, 35, 36, 38, 39, 40, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 109, 110, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 127, 128, 133, 134, 135, 138, 139, 140, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/image_processor.py": [1, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/permissions.py": [1, 4, 6, 7], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/serializers.py": [1, 2, 3, 9, 10, 13, 15, 16, 18, 19, 20, 21, 22, 23, 25, 27, 28, 29, 30, 32, 33, 34, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 49, 50, 53, 54, 55, 56, 59, 62, 64, 65, 67, 68, 69, 70, 71, 73, 74, 77, 78, 79, 80, 81, 83, 84, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 98, 99, 102, 103, 104, 105, 106, 108, 109, 111, 112, 114, 115, 116, 118, 119], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/views.py": [1, 2, 3, 4, 5, 6, 11, 15, 19, 20, 21, 22, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 47, 48, 51, 52, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 83, 99, 101, 102, 105, 106, 108, 109, 110, 112, 128, 130, 131, 134, 135, 136, 137, 138, 139, 141, 143, 144, 148, 149, 150, 151, 152, 153, 154, 156, 157, 160, 178, 179, 180, 181, 182, 186, 204, 205, 206, 207, 208, 211, 229, 230, 231, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 245, 246, 247, 248]}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.env.yml
db.sqlite3
__pycache__
app/app/development.py
app/app/develop.py
app/static_cdn/*
app/media_cdn/*
node_modules
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "2.7"
# command to install dependencies
install:
- pip install -r requirements.txt
script:
- cd app
- python manage.py test
after_success:
- coveralls
1 change: 1 addition & 0 deletions app/.coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/__init__.py": [1], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/views.py": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 18, 20, 21, 22], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/urls.py": [1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/image_edit.py": [1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 27, 31, 32, 34, 36, 38, 40, 42, 44, 45, 47, 49, 51, 53, 55, 57, 58, 59, 60, 61, 63, 65, 66, 67, 69, 71, 72, 74, 76, 77, 78, 80, 82, 83, 84, 86, 88, 90, 92, 93, 94, 96, 98, 99, 101, 103, 104, 106, 110, 113, 116, 118, 120, 122, 124, 128, 135, 140, 145, 146, 147, 148, 150, 151, 152], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/image_processor.py": [1, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/permissions.py": [1, 4, 6, 7], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/serializers.py": [1, 2, 3, 9, 10, 13, 15, 16, 18, 19, 20, 21, 22, 23, 25, 27, 28, 29, 30, 32, 33, 34, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 49, 50, 53, 54, 55, 56, 59, 62, 64, 65, 67, 68, 69, 70, 71, 73, 74, 77, 78, 79, 80, 81, 83, 84, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 98, 99, 102, 103, 104, 105, 106, 108, 109, 111, 112, 114, 115, 116, 118, 119], "/Users/andela/Documents/projects/django-app/photo-editing/app/photos/api/views.py": [1, 2, 3, 4, 5, 6, 11, 15, 19, 20, 21, 22, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 47, 48, 51, 52, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 83, 99, 101, 102, 105, 106, 108, 109, 110, 112, 128, 130, 131, 134, 135, 136, 137, 138, 139, 141, 143, 144, 148, 149, 150, 151, 152, 153, 154, 156, 157, 160, 178, 179, 180, 181, 182, 186, 204, 205, 206, 207, 208, 211, 229, 230, 231, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 246, 247, 248]}}
11 changes: 0 additions & 11 deletions app/app/development.py

This file was deleted.

18 changes: 18 additions & 0 deletions app/app/production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os, sys
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
import dj_database_url

if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'),
}
}
SECRET_KEY = "test-secret"
DEBUG = True
else:
DATABASES = {
'default': dj_database_url.config()
}
DEBUG = False
21 changes: 12 additions & 9 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
import dj_database_url

DATABASES = {
'default': dj_database_url.config()
}

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']
Expand All @@ -40,12 +33,12 @@
SOCIAL_AUTH_TWITTER_SECRET = os.getenv('SOCIAL_AUTH_TWITTER_SECRET')
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
SOCIAL_AUTH_LOGIN_URL = '/'
DEBUG = False
DEBUG = True

try:
from .development import *
except ImportError:
pass
from .production import *

# Application definition

Expand All @@ -58,9 +51,19 @@
'django.contrib.staticfiles',
'rest_framework',
'social.apps.django_app.default',
'django_nose',
'photos',
]


# Use nose to run all tests
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

NOSE_ARGS = [
'--with-coverage',
'--cover-package=photos.api,photos.views',
]

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
Expand Down
1 change: 0 additions & 1 deletion app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
url(r'^$', views.index),
url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^logout/$', views.logout_view),
url(r'^test/$', views.test),
url(r'^api/v1/', include('photos.api.urls', namespace="api")),
]

Expand Down
12 changes: 11 additions & 1 deletion app/photos/api/image_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ def __init__(self, path):
except:
raise ValueError('Unable to open specified image path')

def convert(self, mode="RGB"):
self.output = self.output.convert(mode)

def black_and_white(self):
""" Translates a color image to black and white. """
self.output = self.output.convert('L')
self.convert('L')

def grayscale(self):
""" Convert the image to grayscale. """
self.output = ImageOps.grayscale(self.output)

def invert(self):
""" Negates the image. """
self.convert()
self.output = ImageOps.invert(self.output)

def equalize(self):
Expand Down Expand Up @@ -69,11 +73,13 @@ def gaussian_blur(self, radius):

def auto_contrast(self, cutoff=0):
""" Normalize image contrast. """
self.convert()
actual_value = float(cutoff)/100 * 50
self.output = ImageOps.autocontrast(self.output, int(actual_value))

def posterize(self, bit=1):
""" Reduce the number of bits for each color channel. """
self.convert()
actual_value = float(bit)/100 * 8
self.output = ImageOps.posterize(self.output, int(actual_value))

Expand All @@ -83,6 +89,7 @@ def unsharp_mask(self, radius):

def solarize(self, threshold=128):
""" Invert all pixel values above a threshold """
self.convert()
actual_value = float(threshold)/100 * 256
self.output = ImageOps.solarize(self.output, int(actual_value))

Expand Down Expand Up @@ -142,4 +149,7 @@ def preview(self):

def save(self):
path = self.path.replace('main', 'edited')
edit_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'media_cdn/edited')
if not os.path.exists(edit_path):
os.makedirs(edit_path)
self.output.save(path, format=self.image_format)
5 changes: 1 addition & 4 deletions app/photos/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from django.conf.urls import url
#from rest_framework_jwt.views import obtain_jwt_token
#from rest_framework_jwt.views import refresh_jwt_token
from .views import *

urlpatterns = [
url(r'^auth/register/$', RegistrationApiView.as_view(), name='register'),
url(r'^auth/login/$', LoginApiView.as_view(), name='login'),
url(r'^folders/$', FolderApiView.as_view(), name='list-folder'),
url(r'^folders/$', FolderApiView.as_view(), name='list-folder'),
url(r'^photos/$', PhotoApiView.as_view(), name='list-photo'),
url(r'^folders/(?P<id>\d+)/$', SingleFolderAPIView.as_view(), name='folder-detail'),
url(r'^folders/(?P<id>\d+)/photos/$', PhotoApiView.as_view(), name='folder-photos'),
url(r'^photos/$', PhotoApiView.as_view(), name='list-photo'),
url(r'^photos/(?P<id>\d+)/$', SinglePhotoAPIView.as_view(), name='photo-single'),
url(r'^photos/share/$', PhotoShare.as_view(), name='photo-share'),
url(r'^photos/(?P<id>\d+)/detail/(?P<pk>\d+)/$', PhotoDetailAPIView.as_view(), name='photo-detail'),
Expand Down
11 changes: 6 additions & 5 deletions app/photos/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ def perform_update(self, serializer):
instance = serializer.save()
photo = instance.photo
image_processor = ImageProcessor(photo)
effect_obj = json.loads(instance.effects)
image_processor.process(effect_obj)
edited_path = image_processor.save()
photo.edited_image = edited_path;
photo.save()
if instance.effects:
effect_obj = json.loads(instance.effects)
image_processor.process(effect_obj)
edited_path = image_processor.save()
photo.edited_image = edited_path;
photo.save()



Expand Down
Empty file added app/photos/tests/__init__.py
Empty file.
Loading

0 comments on commit 43eeb80

Please sign in to comment.