Skip to content

Commit e2e25d3

Browse files
committed
Refactoring to look like real repo
1 parent 6d4b31a commit e2e25d3

35 files changed

+194
-27
lines changed

Diff for: .coveragerc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[run]
2+
source = .
3+
4+
[report]
5+
omit = *venv/*

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# environment
2+
/env/
3+
/venv/
4+
15
# Python compiled byte code
26
*.pyc
37

Diff for: Makefile

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.PHONY: test fasttest run lint pep8 eslint
2+
3+
# Project settings
4+
LEVEL ?= development
5+
PROJECT = src
6+
7+
# Virtual environment settings
8+
ENV ?= ./venv
9+
VENV = $(shell python -c "import sys; print(int(hasattr(sys, 'real_prefix')));")
10+
11+
# Python commands
12+
ifeq ($(VENV),1)
13+
ANSIBLE_PLAYBOOK = ansible-playbook
14+
COVERAGE = coverage
15+
FLAKE8 = flake8
16+
GUNICORN = gunicorn
17+
PYTHON = python
18+
else
19+
ANSIBLE_PLAYBOOK = $(ENV)/bin/ansible-playbook
20+
COVERAGE = ${ENV}/bin/coverage
21+
FLAKE8 = $(ENV)/bin/flake8
22+
GUNICORN = $(ENV)/bin/gunicorn
23+
PYTHON = $(ENV)/bin/python
24+
endif
25+
26+
SERVER_HOST ?= 0.0.0.0
27+
SERVER_PORT ?= 8000
28+
29+
# Easy testing
30+
test:
31+
python manage.py test
32+
33+
# Fast testing
34+
fasttest:
35+
REUSE_DB=1 $(MAKE) test
36+
37+
# Run server
38+
run:
39+
python manage.py runserver $(SERVER_HOST):$(SERVER_PORT)
40+
41+
# Linter
42+
lint: pep8
43+
44+
# PEP8 code style
45+
pep8:
46+
ifeq ($(LEVEL),development)
47+
$(FLAKE8) --statistics ./$(PROJECT)/
48+
endif
49+
50+
# JavaScript linter
51+
eslint:
52+
ifeq ($(LEVEL),development)
53+
npm run lint
54+
endif

Diff for: authentication/admin.py

-3
This file was deleted.

Diff for: authentication/tests.py

-3
This file was deleted.

Diff for: circle.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Customize the test machine
2+
machine:
3+
environment:
4+
COVERALLS_REPO_TOKEN: BIJEGOKsEvdhmwdLlC2QMSp1k9tbjwBYk
5+
DATABASE_URL: postgres://ubuntu:@127.0.0.1:5432/circle_test
6+
DJANGO_SETTINGS_MODULE: django_and_angular.settings
7+
LEVEL: development
8+
9+
timezone:
10+
Russia/Moscow # Set the timezone
11+
12+
# Version of ruby to use
13+
python:
14+
version:
15+
2.7.11
16+
17+
test:
18+
override:
19+
- TEST_ARGS=--with-xunit make lint test
20+
21+
post:
22+
- coveralls
23+
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
24+
- "[ -r nosetests.xml ] && mv nosetests.xml $CIRCLE_TEST_REPORTS/junit/ || :"
25+
26+
# # Override /etc/hosts
27+
# hosts:
28+
# circlehost: 127.0.0.1
29+
# dev.mycompany.com: 127.0.0.1
30+
31+
# # Add some environment variables
32+
# environment:
33+
# CIRCLE_ENV: test
34+
# DATABASE_URL: postgres://ubuntu:@127.0.0.1:5432/circle_test
35+
36+
### Customize checkout
37+
#checkout:
38+
# post:
39+
# - git submodule sync
40+
# - git submodule update --init # use submodules
41+
42+
## Customize dependencies
43+
#dependencies:
44+
# pre:
45+
# - npm install coffeescript # install from a different package manager
46+
# - gem uninstall bundler # use a custom version of bundler
47+
# - gem install bundler --pre
48+
49+
# override:
50+
# - bundle install: # note ':' here
51+
# timeout: 180 # fail if command has no output for 3 minutes
52+
53+
# we automatically cache and restore many dependencies between
54+
# builds. If you need to, you can add custom paths to cache:
55+
# cache_directories:
56+
# - "custom_1" # relative to the build directory
57+
# - "~/custom_2" # relative to the user's home directory
58+
59+
## Customize database setup
60+
#database:
61+
# override:
62+
# # replace CircleCI's generated database.yml
63+
# - cp config/database.yml.ci config/database.yml
64+
# - bundle exec rake db:create db:schema:load
65+
66+
## Customize test commands
67+
#test:
68+
# override:
69+
# - phpunit test/unit-tests # use PHPunit for testing
70+
# post:
71+
# - bundle exec rake jasmine:ci: # add an extra test type
72+
# environment:
73+
# RAILS_ENV: test
74+
# RACK_ENV: test
75+
76+
## Customize deployment commands
77+
#deployment:
78+
# staging:
79+
# branch: master
80+
# heroku:
81+
# appname: foo-bar-123
82+
83+
## Custom notifications
84+
#notify:
85+
# webhooks:
86+
# # A list of hashes representing hooks. Only the url field is supported.
87+
# - url: https://someurl.com/hooks/circle

Diff for: posts/admin.py

-3
This file was deleted.

Diff for: posts/tests.py

-3
This file was deleted.

Diff for: requirements-dev.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flake8==2.3.0
2+
flake8-import-order==0.5.3
3+
flake8-pep257==1.0.3
4+
pep257==0.6.0
5+
pep8==1.6.2
6+
pep8-naming==0.3.3

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ django-compressor==1.4
66
djangorestframework==3.0.0
77
drf-nested-routers==0.9.0
88
gunicorn==19.1.1
9+
raven==5.10.2
910
six==1.8.0
1011
static3==0.5.1
1112
wsgiref==0.1.2

Diff for: setup.cfg

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
application-import-names=
3+
authentication,
4+
django_and_angular,
5+
posts
6+
exclude=src/django_and_angular/settings.py,migrations
7+
ignore=D100,D101,D102,D103,D205,D400,N802
8+
import-order-style=google
File renamed without changes.

Diff for: src/authentication/admin.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Register your models here.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: authentication/serializers.py renamed to src/authentication/serializers.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from django.contrib.auth import update_session_auth_hash
2-
32
from rest_framework import serializers
43

5-
from authentication.models import Account
4+
from .models import Account
65

76

87
class AccountSerializer(serializers.ModelSerializer):
@@ -20,7 +19,9 @@ def create(self, validated_data):
2019
return Account.objects.create(**validated_data)
2120

2221
def update(self, instance, validated_data):
23-
instance.username = validated_data.get('username', instance.username)
22+
instance.username = validated_data.get(
23+
'username', instance.username
24+
)
2425
instance.tagline = validated_data.get('tagline', instance.tagline)
2526

2627
instance.save()

Diff for: src/authentication/tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Create your tests here.

Diff for: authentication/views.py renamed to src/authentication/views.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.contrib.auth import authenticate, login, logout
44

5-
from rest_framework import permissions, viewsets, status, views
5+
from rest_framework import permissions, status, views, viewsets
66
from rest_framework.response import Response
77

88
from authentication.models import Account
@@ -30,7 +30,10 @@ def create(self, request):
3030
if serializer.is_valid():
3131
Account.objects.create_user(**serializer.validated_data)
3232

33-
return Response(serializer.validated_data, status=status.HTTP_201_CREATED)
33+
return Response(
34+
serializer.validated_data,
35+
status=status.HTTP_201_CREATED
36+
)
3437

3538
return Response({
3639
'status': 'Bad request',
File renamed without changes.
File renamed without changes.

Diff for: django_and_angular/urls.py renamed to src/django_and_angular/urls.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from django.conf.urls import patterns, url, include
2-
3-
from django_and_angular.views import IndexView
1+
from django.conf.urls import include, patterns, url
42
from rest_framework_nested import routers
53

64
from authentication.views import AccountViewSet, LoginView, LogoutView
75
from posts.views import AccountPostsViewSet, PostViewSet
86

7+
from .views import IndexView
8+
9+
910
router = routers.SimpleRouter()
1011
router.register(r'accounts', AccountViewSet)
1112
router.register(r'posts', PostViewSet)
@@ -17,7 +18,7 @@
1718

1819

1920
urlpatterns = patterns(
20-
'',
21+
'',
2122
url(r'^api/v1/', include(router.urls)),
2223
url(r'^api/v1/auth/login/$', LoginView.as_view(), name='login'),
2324
url(r'^api/v1/auth/logout/$', LogoutView.as_view(), name='logout'),

Diff for: django_and_angular/views.py renamed to src/django_and_angular/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from django.utils.decorators import method_decorator
12
from django.views.decorators.csrf import ensure_csrf_cookie
23
from django.views.generic.base import TemplateView
3-
from django.utils.decorators import method_decorator
44

55

66
class IndexView(TemplateView):

Diff for: django_and_angular/wsgi.py renamed to src/django_and_angular/wsgi.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flake8: noqa
12
"""
23
WSGI config for DjangoAndAngular project.
34
@@ -11,6 +12,6 @@
1112
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_and_angular.settings")
1213

1314
from django.core.wsgi import get_wsgi_application
14-
from dj_static import Cling
15+
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
1516

16-
application = Cling(get_wsgi_application())
17+
application = Sentry(get_wsgi_application())

Diff for: manage.py renamed to src/manage.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import sys
44

55
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_and_angular.settings")
6+
os.environ.setdefault(
7+
"DJANGO_SETTINGS_MODULE",
8+
"django_and_angular.settings"
9+
)
710

811
from django.core.management import execute_from_command_line
912

File renamed without changes.

Diff for: src/posts/admin.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Register your models here.
File renamed without changes.
File renamed without changes.

Diff for: posts/models.py renamed to src/posts/models.py

File renamed without changes.
File renamed without changes.

Diff for: posts/serializers.py renamed to src/posts/serializers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from rest_framework import serializers
22

33
from authentication.serializers import AccountSerializer
4-
from posts.models import Post
4+
5+
from .models import Post
56

67

78
class PostSerializer(serializers.ModelSerializer):

Diff for: src/posts/tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Create your tests here.

Diff for: posts/views.py renamed to src/posts/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_permissions(self):
1616
return (permissions.IsAuthenticated(), IsAuthorOfPost(),)
1717

1818
def perform_create(self, serializer):
19-
instance = serializer.save(author=self.request.user)
19+
serializer.save(author=self.request.user)
2020
return super(PostViewSet, self).perform_create(serializer)
2121

2222

0 commit comments

Comments
 (0)