Skip to content

Commit

Permalink
Add RestAPI and rename django_curriculum by curriculum
Browse files Browse the repository at this point in the history
  • Loading branch information
axeliodiaz committed Jul 19, 2017
1 parent 70e5f30 commit aab8e5e
Show file tree
Hide file tree
Showing 18 changed files with 204 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Ready to contribute? Here's how to set up `django-curriculum` for local developm
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::

$ flake8 django_curriculum tests
$ flake8 curriculum tests
$ python setup.py test
$ tox

Expand Down
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ History
* Add details to run makemigrations and migrate.
* Add language register and include all ModelAdmin.
* Add TimeStampedModel to Overview

0.1.13 (2017-07-19)
++++++++++++++++++

* Add Rest API
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include django_curriculum *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
recursive-include curriculum *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clean-pyc: ## remove Python file artifacts
find . -name '*~' -exec rm -f {} +

lint: ## check style with flake8
flake8 django_curriculum tests
flake8 curriculum tests

test: ## run tests quickly with the default Python
python runtests.py tests
Expand All @@ -37,15 +37,15 @@ test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source django_curriculum runtests.py tests
coverage run --source curriculum runtests.py tests
coverage report -m
coverage html
open htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/django-curriculum.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ django_curriculum
sphinx-apidoc -o docs/ curriculum
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
Expand Down
12 changes: 11 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ Add it to your `INSTALLED_APPS`:
...
)
And create migrations and migrate the models: ::
Create migrations and migrate the models: ::

python manage.py makemigrations curriculum
python manage.py migrate curriculum

Add the urls.py to access the API Rest: ::

urlpatterns = [
...
url(r'^api/curriculum/', include('curriculum.urls')),
...
]

All API urls by default are in: http://localhost:8000/api/curriculum/

Features
--------

Expand Down
2 changes: 1 addition & 1 deletion curriculum/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.12'
__version__ = '0.1.13'
2 changes: 1 addition & 1 deletion curriculum/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@


class DjangoCurriculumConfig(AppConfig):
name = 'django_curriculum'
name = 'curriculum'
74 changes: 74 additions & 0 deletions curriculum/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from rest_framework import serializers
from .models import (Overview, PersonalSocialMedia, PersonalPhone,
EducationInfo, JobInfo, Accomplishment, Skillset,
Skill, Language, LanguageInfo)


class OverviewSerializer(serializers.ModelSerializer):

class Meta:
model = Overview
fields = '__all__'


class PersonalSocialMediaSerializer(serializers.ModelSerializer):

class Meta:
model = PersonalSocialMedia
fields = '__all__'


class PersonalPhoneSerializer(serializers.ModelSerializer):

class Meta:
model = PersonalPhone
fields = '__all__'


class EducationInfoSerializer(serializers.ModelSerializer):

class Meta:
model = EducationInfo
fields = '__all__'


class JobInfoSerializer(serializers.ModelSerializer):

class Meta:
model = JobInfo
fields = '__all__'


class AccomplishmentSerializer(serializers.ModelSerializer):

class Meta:
model = Accomplishment
fields = '__all__'


class SkillsetSerializer(serializers.ModelSerializer):

class Meta:
model = Skillset
fields = '__all__'


class SkillSerializer(serializers.ModelSerializer):

class Meta:
model = Skill
fields = '__all__'


class LanguageSerializer(serializers.ModelSerializer):

class Meta:
model = Language
fields = '__all__'


class LanguageInfoSerializer(serializers.ModelSerializer):

class Meta:
model = LanguageInfo
fields = '__all__'
16 changes: 12 additions & 4 deletions curriculum/urls.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.conf.urls import url, include
from django.views.generic import TemplateView
from rest_framework import routers

from . import views

router.register(r'projects', views.ProjectViewSet)
router = routers.DefaultRouter()
router.register(r'overview', views.OverviewViewSet)
router.register(r'socialmedia', views.PersonalSocialMediaViewSet)
router.register(r'education', views.EducationInfoViewSet)
router.register(r'job', views.JobInfoViewSet)
router.register(r'acomplishment', views.AccomplishmentViewSet)
router.register(r'skillet', views.SkillsetViewSet)
router.register(r'skill', views.SkillViewSet)
router.register(r'language', views.LanguageViewSet)
router.register(r'languageinfo', views.LanguageInfoViewSet)

urlpatterns = [
url(r'', TemplateView.as_view(template_name="base.html")),
url(r'^api/', include(router.urls)),
url(r'^', include(router.urls)),
]
77 changes: 74 additions & 3 deletions curriculum/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,83 @@
from rest_framework import viewsets
from django.utils.translation import ugettext_lazy as _

from .models import Overview
from .models import (Overview, PersonalSocialMedia, PersonalPhone,
EducationInfo, JobInfo, Accomplishment, Skillset, Skill,
Language, LanguageInfo)
from .serializers import (OverviewSerializer, PersonalSocialMediaSerializer,
PersonalPhoneSerializer, EducationInfoSerializer,
JobInfoSerializer, AccomplishmentSerializer,
SkillsetSerializer, SkillSerializer,
LanguageSerializer, LanguageInfoSerializer)


class OverviewViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = Overview.objects.all().order_by('-created')
serializer_class = ProjectSerializer
queryset = Overview.objects.filter().order_by('-created')
serializer_class = OverviewSerializer


class PersonalSocialMediaViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = PersonalSocialMedia.objects.filter().order_by('-created')
serializer_class = PersonalSocialMediaSerializer


class EducationInfoViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = EducationInfo.objects.filter().order_by('-created')
serializer_class = EducationInfoSerializer


class JobInfoViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = JobInfo.objects.filter().order_by('-created')
serializer_class = JobInfoSerializer


class AccomplishmentViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = Accomplishment.objects.filter().order_by('-created')
serializer_class = AccomplishmentSerializer


class SkillsetViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = Skillset.objects.filter().order_by('-created')
serializer_class = SkillsetSerializer


class SkillViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = Skill.objects.filter().order_by('-created')
serializer_class = SkillSerializer


class LanguageViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = Language.objects.filter().order_by('-created')
serializer_class = LanguageSerializer


class LanguageInfoViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = LanguageInfo.objects.filter().order_by('-created')
serializer_class = LanguageInfoSerializer
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
parent = os.path.dirname(cwd)
sys.path.append(parent)

import django_curriculum
import curriculum

# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = django_curriculum.__version__
version = curriculum.__version__
# The full version, including alpha/beta/rc tags.
release = django_curriculum.__version__
release = curriculum.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
12 changes: 8 additions & 4 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ To use django-curriculum in a project, add it to your `INSTALLED_APPS`:
INSTALLED_APPS = (
...
'django_curriculum.apps.DjangoCurriculumConfig',
'curriculum',
...
)
Create migrations and run migrations: ::

python manage.py makemigrations curriculum
python manage.py migrate curriculum


Add django-curriculum's URL patterns:

.. code-block:: python
from django_curriculum import urls as django_curriculum_urls
urlpatterns = [
...
url(r'^', include(django_curriculum_urls)),
url(r'^api/curriculum/', include('curriculum.urls')),
...
]
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ tag = True

[bumpversion:file:setup.py]

[bumpversion:file:django_curriculum/__init__.py]
[bumpversion:file:curriculum/__init__.py]

[wheel]
universal = 1

[flake8]
ignore = D203
exclude =
django_curriculum/migrations,
curriculum/migrations,
.git,
.tox,
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def get_version(*file_paths):
"""Retrieves the version from django_curriculum/__init__.py"""
"""Retrieves the version from curriculum/__init__.py"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
Expand All @@ -21,7 +21,7 @@ def get_version(*file_paths):
raise RuntimeError('Unable to find version string.')


version = get_version("django_curriculum", "__init__.py")
version = get_version("curriculum", "__init__.py")


if sys.argv[-1] == 'publish':
Expand Down Expand Up @@ -53,7 +53,7 @@ def get_version(*file_paths):
author_email='diaz.axelio@gmail.com',
url='https://github.com/axeliodiaz/django-curriculum',
packages=[
'django_curriculum',
'curriculum',
],
include_package_data=True,
install_requires=[],
Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"django_curriculum",
"curriculum",
]

SITE_ID = 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from django.test import TestCase

from django_curriculum import models
from curriculum import models


class TestDjango_curriculum(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from django.conf.urls import url, include

from django_curriculum.urls import urlpatterns as django_curriculum_urls
from curriculum.urls import urlpatterns as django_curriculum_urls

urlpatterns = [
url(r'^', include(django_curriculum_urls, namespace='django_curriculum')),
url(r'^', include(django_curriculum_urls, namespace='curriculum')),
]

0 comments on commit aab8e5e

Please sign in to comment.