Skip to content

Commit

Permalink
reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmarcondes committed Nov 16, 2014
1 parent 514b838 commit 66717e0
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 261 deletions.
29 changes: 0 additions & 29 deletions portal/settings.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
"""
Django settings for portal project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

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


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['REVUO_KEY']

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('REVUO_DEBUG', False)

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'revuo',
'django_summernote',
Expand All @@ -53,9 +30,6 @@

WSGI_APPLICATION = 'portal.wsgi.application'




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

Expand All @@ -73,7 +47,6 @@

ALLOWED_HOSTS = ['*']

import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
Expand All @@ -90,9 +63,7 @@

LOGIN_URL = '/login/'


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

if DEBUG:
debug_db = os.path.join(BASE_DIR, 'db.sqlite3')
Expand Down
3 changes: 2 additions & 1 deletion revuo/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from revuo.models import Author, NewsItem, BlogItem, Publication
from revuo.models.author import Author
from revuo.models.publications import NewsItem, BlogItem, Publication

admin.site.register(Author)
admin.site.register(NewsItem)
Expand Down
5 changes: 3 additions & 2 deletions revuo/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import forms
from django_summernote.widgets import SummernoteWidget, SummernoteInplaceWidget
from revuo.models import NewsItem, BlogItem, Author, Publication
from django_summernote.widgets import SummernoteWidget
from revuo.models.author import Author
from revuo.models.publications import NewsItem, BlogItem


class FormNewsItem(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion revuo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Migration(migrations.Migration):
('authorized', models.BooleanField(default=False)),
('title', models.TextField(max_length=140)),
('description', models.TextField(max_length=280)),
('attachment', models.FileField(upload_to=revuo.models.publication_destination)),
('attachment', models.FileField(upload_to=revuo.models.publications.publication_destination)),
('author', models.ForeignKey(to='revuo.Author')),
],
options={
Expand Down
21 changes: 21 additions & 0 deletions revuo/migrations/0002_auto_20141116_0103.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('revuo', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='admin',
name='user',
),
migrations.DeleteModel(
name='Admin',
),
]
3 changes: 3 additions & 0 deletions revuo/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import publications
from publications import BlogItem, NewsItem, Publication
from author import Author
13 changes: 13 additions & 0 deletions revuo/models/author.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.db import models
from django.contrib.auth.models import User

class Author(models.Model):
user = models.OneToOneField(User)
editor = models.BooleanField(default=False)
about = models.TextField(max_length=1024)

def __unicode__(self):
return ' '.join([self.user.first_name, self.user.last_name])

def get_url(self):
return '/staff/{}'.format(self.id)
37 changes: 1 addition & 36 deletions revuo/models.py → revuo/models/publications.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
from django.db import models
from django.contrib.auth.models import User
import datetime


class Author(models.Model):
user = models.OneToOneField(User)
editor = models.BooleanField(default=False)
about = models.TextField(max_length=1024)


def __unicode__(self):
return ' '.join([self.user.first_name, self.user.last_name])


def get_url(self):
return '/staff/{}'.format(self.id)


class Admin(models.Model):
user = models.OneToOneField(User)


def __unicode__(self):
return ' '.join([self.user.first_name, self.user.last_name])


class NewsItem(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
Expand All @@ -34,15 +9,12 @@ class NewsItem(models.Model):
description = models.TextField(max_length=280)
text = models.TextField()


def authorize(self):
self.authorized = True


def __unicode__(self):
return self.title


def get_url(self):
return '/N/{}'.format(self.id)

Expand All @@ -56,19 +28,15 @@ class BlogItem(models.Model):
description = models.TextField(max_length=280)
text = models.TextField()


def authorize(self):
self.authorized = True


def __unicode__(self):
return self.title


def get_url(self):
return '/B/{}'.format(self.id)


def publication_destination(instance, filename):
return '_'.join([str(instance.author.id),filename])

Expand All @@ -82,14 +50,11 @@ class Publication(models.Model):
description = models.TextField(max_length=280)
attachment = models.FileField(upload_to=publication_destination)


def authorize(self):
self.authorized = True


def get_url(self):
return '/P/{}'.format(self.id)


def __unicode__(self):
return self.title
return self.title
11 changes: 8 additions & 3 deletions revuo/templates/revuo/base.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{% load staticfiles %}

<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
<link href="{% static "basic-template.css" %}" rel="stylesheet">
<link href="{% static 'basic-template.css' %}" rel="stylesheet">
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="http://getbootstrap.com/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<title>{% block title %}{% endblock %}</title>
Expand Down Expand Up @@ -45,6 +44,12 @@
<li class="dropdown-header">Moderation</li>
<li><a href="{% url 'revuo:publisher' %}">Pending Items</a></li>
{% endif %}
{% if user.is_superuser %}
<li class="divider"></li>
<li class="dropdown-header">Site Administration</li>
<li><a href="#">Settings</a></li>
<li><a href="#">Preferences</a></li>
{% endif %}
<li class="divider"></li>
<li><a href="{% url 'revuo:logout' %}">Logout</a></li>
{% else %}
Expand Down
16 changes: 2 additions & 14 deletions revuo/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.test import LiveServerTestCase, TestCase
from selenium import webdriver
from model_mommy import mommy
from revuo.models import Author, Admin, NewsItem, BlogItem, Publication
from revuo.models.author import Author
from revuo.models.publications import NewsItem, BlogItem, Publication
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from time import sleep
Expand Down Expand Up @@ -303,19 +304,6 @@ def test_author_model(self):
' '.join([author.user.first_name, author.user.last_name])
)


def test_admin_model(self):
"""
admin model test
"""
admin = mommy.make(Admin)
self.assertTrue(isinstance(admin, Admin))
self.assertEqual(
admin.__unicode__(),
' '.join([admin.user.first_name, admin.user.last_name])
)


def test_items_model(self):
"""
item model test
Expand Down
10 changes: 6 additions & 4 deletions revuo/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.conf.urls import patterns, include, url

from revuo.views import Home, Staff, StaffView
from revuo.views import ItemList, ItemView, NewItem
from revuo.views import EditProfile, Publisher, PublishItem, TrashItem
from revuo.views.home import Home
from revuo.views.create import NewItem, EditProfile
from revuo.views.list import ItemList, StaffList
from revuo.views.view import ItemView, StaffView
from revuo.views.moderation import Publisher, PublishItem, TrashItem

urlpatterns = patterns('',
url(r'^$', Home.as_view(), name='home'),
Expand All @@ -11,7 +13,7 @@
url(r'^publications$', ItemList.as_view(category='publications'),
name='publications'),
url(r'^(?P<category>[NBP])/(?P<item_id>\d+)$', ItemView.as_view()),
url(r'^staff$', Staff.as_view(), name='staff'),
url(r'^staff$', StaffList.as_view(), name='staff'),
url(r'^staff/(?P<staff_id>\d+)$', StaffView.as_view()),
url(r'^restricted/N/add$', NewItem.as_view(category='N'),
name='add_news'),
Expand Down
Loading

0 comments on commit 66717e0

Please sign in to comment.