Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open
Commits
182d3fef
Commit
182d3fef
authored
Apr 02, 2017
by
David Haynes
🙆
Browse files
Merge branch '43-python-3' into 'upgrade-django'
Resolve "Port to Python 3" See merge request
!13
parents
058b07c3
b7dd94fa
Pipeline
#1216
passed with stage
in 23 seconds
Changes
16
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
182d3fef
...
...
@@ -13,3 +13,4 @@ whats_open/secret_key.py
whats_open/assets/
static/admin/
data
whats_open/website/migrations
\ No newline at end of file
.gitlab-ci.yml
View file @
182d3fef
...
...
@@ -15,5 +15,17 @@ whats-open-py2.7:
type
:
test
script
:
-
python manage.py test
whats-open-py3.5
:
image
:
library/python:3.5
type
:
test
script
:
-
python manage.py test
whats-open-py3.6
:
image
:
library/python:3.6
type
:
test
script
:
-
python manage.py test
-
coverage run --source=website --omit=*migrations/*,*admin.py,*__init__.py,*.pyc manage.py test
-
coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
Dockerfile
View file @
182d3fef
...
...
@@ -18,7 +18,7 @@
# (You'll need to reverse proxy port 8000 via nginx)
# Set the base image to Ubuntu
FROM
python:
2.7
FROM
python:
3.6
ENV
PYTHONUNBUFFERED 1
# File Author / Maintainer
...
...
README.md
View file @
182d3fef
...
...
@@ -160,18 +160,19 @@ Open a terminal and run the following command:
Next, with:
sudo apt install python python-dev python-pip
sudo pip install virtualenv
sudo apt install python
3
python
3
-dev python
3
-pip
sudo pip
3
install virtualenv
you install
`python`
,
`pip`
, and
`virtualenv`
.
Next with,
virtualenv
v
en
v
source
v
en
v
/bin/activate
virtualenv
-p python3 whats_op
en
source
whats_op
en/bin/activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
cd whats_open/
python3 manage.py makemigrations
python3 manage.py migrate
you setup the project.
...
...
@@ -179,7 +180,7 @@ you setup the project.
Now that everything is set-up you can run the server on your computer.
python manage.py runserver
python
3
manage.py runserver
Go to
[
http://127.0.0.1:8000/
](
)
in your browser and you should see the website.
...
...
whats_open/website/admin.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Django Imports
from
django.contrib
import
admin
# App Imports
from
.models
import
Facility
,
Schedule
,
OpenTime
,
Category
class
OpenTimeInline
(
admin
.
TabularInline
):
...
...
whats_open/website/api.py
View file @
182d3fef
from
models
import
Facility
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Python stdlib Imports
import
re
# App Imports
from
.models
import
Facility
def
export_data
():
facilities
=
list
()
...
...
whats_open/website/models.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Python stdlib Imports
import
datetime
# Django Imports
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
model_utils.models
import
TimeStampedModel
from
autoslug
import
AutoSlugField
import
datetime
class
Category
(
TimeStampedModel
):
name
=
models
.
CharField
(
max_length
=
100
)
...
...
@@ -13,7 +20,7 @@ class Category(TimeStampedModel):
# Sort by name in admin view
ordering
=
[
'name'
]
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
'%s'
%
self
.
name
class
Facility
(
TimeStampedModel
):
...
...
@@ -60,7 +67,7 @@ class Facility(TimeStampedModel):
return
True
return
False
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
name
class
Schedule
(
TimeStampedModel
):
...
...
@@ -88,7 +95,7 @@ class Schedule(TimeStampedModel):
return
True
return
False
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
name
...
...
@@ -144,7 +151,7 @@ class OpenTime(TimeStampedModel):
return
False
return
True
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
weekdays
=
[
'Monday'
,
'Tuesday'
,
'Wednesday'
,
'Thursday'
,
'Friday'
,
'Saturday'
,
'Sunday'
]
return
'%s %s to %s %s'
%
(
weekdays
[
self
.
start_day
],
...
...
whats_open/website/serializers.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# App Imports
from
.models
import
Category
,
Facility
,
Schedule
,
OpenTime
# Other Imports
from
rest_framework
import
serializers
from
website.models
import
Category
,
Facility
,
Schedule
,
OpenTime
class
CategorySerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
...
...
whats_open/website/tests/api_tests.py
deleted
100644 → 0
View file @
058b07c3
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from
django.test
import
TestCase
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
whats_open/website/tests/forms_tests.py
deleted
100644 → 0
View file @
058b07c3
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from
django.test
import
TestCase
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
whats_open/website/tests/model_tests.py
deleted
100644 → 0
View file @
058b07c3
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from
django.test
import
TestCase
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
whats_open/website/tests/view_tests.py
deleted
100644 → 0
View file @
058b07c3
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from
django.test
import
TestCase
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
whats_open/website/urls.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Django Imports
from
django.conf.urls
import
include
,
url
...
...
whats_open/website/views.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Python stdlib Imports
import
hashlib
import
json
# Django Imports
from
django.template
import
RequestContext
from
website.models
import
Facility
,
OpenTime
from
website.api
import
export_data
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponse
from
django.views.decorators.http
import
condition
from
django.views.generic
import
ListView
,
DetailView
from
model_utils.models
import
TimeStampedModel
from
website.models
import
Facility
,
OpenTime
,
Category
,
Schedule
from
website.api
import
export_data
from
website.serializers
import
CategorySerializer
,
FacilitySerializer
,
ScheduleSerializer
,
OpenTimeSerializer
# App Imports
from
.models
import
Facility
,
OpenTime
,
Category
,
Schedule
from
.api
import
export_data
from
.serializers
import
CategorySerializer
,
FacilitySerializer
,
ScheduleSerializer
,
OpenTimeSerializer
# Other Imports
from
rest_framework
import
viewsets
,
status
from
rest_framework.response
import
Response
from
rest_framework.decorators
import
api_view
import
hashlib
import
json
# Rest Framework Class Views
class
CategoryViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
queryset
=
Category
.
objects
.
all
()
...
...
@@ -33,9 +39,9 @@ class FacilityViewSet(viewsets.ReadOnlyModelViewSet):
if
open_now
is
not
None
:
results
=
[]
for
fac
in
queryset
:
print
fac
print
(
fac
)
if
fac
.
isOpen
():
print
True
print
(
True
)
results
.
append
(
fac
)
return
results
else
:
...
...
whats_open/whats_open/settings/production.py
View file @
182d3fef
...
...
@@ -15,7 +15,7 @@ def get_env_setting(setting):
""" Get the environment setting or return exception """
try
:
return
environ
[
setting
]
except
KeyError
:
except
KeyError
as
ex
:
error_msg
=
"Set the %s env variable"
%
setting
raise
ImproperlyConfigured
(
error_msg
)
...
...
whats_open/whats_open/urls.py
View file @
182d3fef
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Django Imports
from
django.conf.urls
import
include
,
url
from
django.contrib
import
admin
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment