Skip to content
This repository was archived by the owner on Jul 17, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ tramp
Thumbs.db
Desktop.ini

env*
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Dependencies
------------

- `Django 1.8 <https://pypi.python.org/pypi/Django/1.8>`__
- `djangorestframework 3.2.2 <http://django-rest-framework.org>`__
- `django-braces 1.4.0 <https://pypi.python.org/pypi/django-braces/1.4.0>`__
- `factory_boy 2.5.1 <https://pypi.python.org/pypi/factory_boy/2.5.1>`__
- `feedparser 5.2.0 <https://pypi.python.org/pypi/feedparser/5.2.0>`__
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sqlite3
Empty file added example/example/__init__.py
Empty file.
109 changes: 109 additions & 0 deletions example/example/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"""
Django settings for example project.

Generated by 'django-admin startproject' using Django 1.8.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'rozpjhivw(nj_3@zp*c6$5zlf=%x+zug6uju8eceqo$hj81+m%'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Account stuff
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
REGISTRATION_AUTO_LOGIN = True # Automatically log the user in.

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
# 'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
'feedreader',
'rest_framework'
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'example.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'example.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions example/example/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""example URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^feedreader/', include('feedreader.urls', namespace='feedreader')),
]
16 changes: 16 additions & 0 deletions example/example/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for example project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")

application = get_wsgi_application()
10 changes: 10 additions & 0 deletions example/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
2 changes: 2 additions & 0 deletions example/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
django-registration-redux==1.2
djangorestframework==3.2.2
36 changes: 36 additions & 0 deletions feedreader/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from rest_framework import viewsets

from .models import Entry, Feed, Group, Options
from .serializers import EntrySerializer, FeedSerializer, GroupSerializer, OptionsSerializer


class OptionsViewSet(viewsets.ReadOnlyModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = Options.objects.all()
serializer_class = OptionsSerializer


class GroupViewSet(viewsets.ReadOnlyModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer


class FeedViewSet(viewsets.ReadOnlyModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = Feed.objects.all()
serializer_class = FeedSerializer


class EntryViewSet(viewsets.ReadOnlyModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = Entry.objects.all()
serializer_class = EntrySerializer
89 changes: 89 additions & 0 deletions feedreader/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from __future__ import absolute_import
from rest_framework import serializers

from .models import Entry, Feed, Group, Options


class OptionsSerializer(serializers.ModelSerializer):
"""
Options controlling feedreader behavior

:Fields:

number_initially_displayed : integer
Number of entries, from all feeds, initially displayed on webpage.
number_additionally_displayed : integer
Number of entries added to displayed results when scrolling down.
max_entries_saved : integer
Maximum number of entries to store for each feed.
"""

class Meta:
model = Options


class GroupSerializer(serializers.ModelSerializer):
"""
Group of feeds.

:Fields:

name : char
Name of group.
num_unread_entries: int
"""

class Meta:
model = Group


class FeedSerializer(serializers.ModelSerializer):
"""
Feed information.

:Fields:

title : char
Title of feed.
xml_url : char
URL of xml feed.
link : char
URL of feed site.
description : text
Description of feed.
published_time : date_time
When feed was last updated.
last_polled_time : date_time
When feed was last polled.
group : ForeignKey
Group this feed is a part of.
num_unread_entries
"""

class Meta:
model = Feed


class EntrySerializer(serializers.ModelSerializer):
"""
Feed entry information.

:Fields:

feed : ForeignKey
Feed this entry is a part of.
title : char
Title of entry.
link : char
URL of entry.
description : text
Description of entry.
published_time : date_time
When entry was last updated.
read_flag: boolean
Has the entry been read?
"""

class Meta:
model = Entry

Loading