Skip to content
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
26 changes: 12 additions & 14 deletions conf/requirements.pip
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
python-memcached==1.48
pymongo==2.3
django==1.4.1
django-compressor==1.2
django-gravatar==0.1.0
django-tastypie==0.9.11
django-social-auth==0.7.7
django-debug-toolbar==0.9.4
nltk==2.0.3
numpy==1.6.2
south==0.7.6
lettuce==0.2.12
django-markitup==1.0.0
markdown==2.2.0
pymongo==3.5.1
django==1.11.6
django-compressor==2.2
django-gravatar2==1.4.2
django-tastypie==0.14.0
django-debug-toolbar==1.8
nltk==3.2.4
numpy==1.13.1
lettuce==0.2.23
django-markitup==3.0.0
markdown==2.6.9
django-allauth==0.33.0
6 changes: 3 additions & 3 deletions web/dbpatterns/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from django.conf.urls import patterns, url, include
from django.conf.urls import url, include

from documents.resources import DocumentResource
from comments.resources import CommentResource
from profiles.resources import UserResource

urlpatterns = patterns('',
urlpatterns = [
url(r'^', include(DocumentResource().urls)),
url(r'^', include(CommentResource().urls)),

# django views
url(r'^users/$', UserResource.as_view()),
)
]
75 changes: 32 additions & 43 deletions web/dbpatterns/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'Post'
db.create_table('blog_post', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=255)),
('content', self.gf('markitup.fields.MarkupField')(no_rendered_field=True)),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, auto_now_add=True, blank=True)),
('is_published', self.gf('django.db.models.fields.BooleanField')(default=True)),
('_content_rendered', self.gf('django.db.models.fields.TextField')(blank=True)),
))
db.send_create_signal('blog', ['Post'])


def backwards(self, orm):
# Deleting model 'Post'
db.delete_table('blog_post')


models = {
'blog.post': {
'Meta': {'ordering': "('-date_created',)", 'object_name': 'Post'},
'_content_rendered': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'content': ('markitup.fields.MarkupField', [], {'no_rendered_field': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
}
}

complete_apps = ['blog']
# Generated by Django 1.11.6 on 2017-10-18 21:40
from __future__ import unicode_literals

from django.db import migrations, models
import markitup.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255, verbose_name='Name')),
('slug', models.SlugField(max_length=255, unique=True, verbose_name='Slug')),
('content', markitup.fields.MarkupField(no_rendered_field=True, verbose_name='Content')),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('is_published', models.BooleanField(default=True, verbose_name='Published')),
('_content_rendered', models.TextField(blank=True, editable=False)),
],
options={
'ordering': ('-date_created',),
},
),
]
2 changes: 1 addition & 1 deletion web/dbpatterns/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Post(models.Model):
slug = models.SlugField(_("Slug"), max_length=255, unique=True)
content = MarkupField(_("Content"))
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True, auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
is_published = models.BooleanField(_("Published"), default=True)

objects = models.Manager()
Expand Down
10 changes: 6 additions & 4 deletions web/dbpatterns/blog/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.conf.urls import patterns, url
from django.conf.urls import url

from django.contrib.sitemaps.views import sitemap

from blog.sitemaps import BlogSitemap
from blog.views import (BlogDetailView, BlogIndexView,
BlogPostsRssFeed, BlogPostsAtomFeed)


urlpatterns = patterns('',
urlpatterns = [
# blog urls
url(r'^$', BlogIndexView.as_view(), name="blog"),
url(r'^(?P<slug>[-\w]+)/$', BlogDetailView.as_view(), name="blog_detail"),
Expand All @@ -15,8 +17,8 @@
url(r'^feed/atom', BlogPostsAtomFeed(), name="blog_atom_feed"),

# sitemap
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
url(r'^sitemap\.xml$', sitemap,
{'sitemaps': {
"blog": BlogSitemap()
}}, name="blog_sitemap"),
)
]
4 changes: 2 additions & 2 deletions web/dbpatterns/comments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from gravatar.templatetags.gravatar import gravatar_for_email
from django_gravatar.templatetags.gravatar import gravatar_url
from newsfeed.constants import NEWS_TYPE_COMMENT

from profiles.models import AnonymousProfile
Expand Down Expand Up @@ -31,7 +31,7 @@ def profile_url(self):
@property
def avatar_url(self):
"""Returns the gravar address of email"""
return gravatar_for_email(self.user.email, size=40)
return gravatar_url(self.user.email, size=40)

@property
def username(self):
Expand Down
83 changes: 23 additions & 60 deletions web/dbpatterns/dbpatterns/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
Expand Down Expand Up @@ -67,36 +66,24 @@
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
'compressor.finders.CompressorFinder',
)


# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware'
)
]

ROOT_URLCONF = 'dbpatterns.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'dbpatterns.wsgi.application'

TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), "templates")
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -107,9 +94,7 @@
'django.contrib.admin',
'django.contrib.humanize',

'south',
'gravatar',
'social_auth',
'django_gravatar',
'compressor',
'debug_toolbar',
'lettuce.django',
Expand All @@ -121,19 +106,24 @@
'blog',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.csrf',
'django.contrib.messages.context_processors.messages',

'notifications.context_processors.notifications'

)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(__file__), "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.core.context_processors.static',
'django.core.context_processors.i18n',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'notifications.context_processors.notifications'
],
},
},
]


# A sample logging configuration. The only tangible logging
Expand Down Expand Up @@ -167,27 +157,8 @@

# Social Auth Settings

AUTHENTICATION_BACKENDS = (
'social_auth.backends.contrib.github.GithubBackend',
'django.contrib.auth.backends.ModelBackend',
)

LOGIN_REDIRECT_URL = '/'

SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'

SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
)


# MONGODB Settings

MONGODB_DATABASE = "dbpatterns"
Expand All @@ -214,17 +185,9 @@
"INTERCEPT_REDIRECTS": False
}

# Memcached Settings
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}

# Testing
LETTUCE_SERVER_PORT = 7000
SOUTH_TESTS_MIGRATE = False

# Markitup Settings
MARKITUP_SET = 'markitup/sets/markdown'
Expand All @@ -239,6 +202,6 @@
SOCKETIO_HOST = "http://localhost:8000"

try:
from settings_local import *
from settings_local import * # noqa
except ImportError:
pass
pass
3 changes: 1 addition & 2 deletions web/dbpatterns/dbpatterns/settings_local.py.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

DEBUG = True
TEMPLATE_DEBUG = True

COMPRESS_ENABLED = False

Expand All @@ -21,4 +20,4 @@ GITHUB_APP_ID = "<<< GITHUB APP ID >>>"
GITHUB_API_SECRET = "<<< GITHUB SECRET KEY >>"

# Make this unique, and don't share it with anybody.
SECRET_KEY = '<<< SECRET KEY >>>'
SECRET_KEY = 'g3a#n@4)q&9p7fx&uix9+abfi_#l_wr6uk&!plax$6)7*i(9vh'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to remove the above line, SECRET_KEY = '<<< SECRET KEY >>>'
It doesn't harm much considering the sample file. Just a comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review. I didn't complete yet this PR. that's why some variables are hardcoded like SECRET_KEY . When I completed it, I will clean up.

9 changes: 3 additions & 6 deletions web/dbpatterns/dbpatterns/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib import admin
from documents.views import HomeView


admin.autodiscover()

urlpatterns = patterns('',
urlpatterns = [

url(r'^$', HomeView.as_view(), name='home'),

Expand All @@ -28,7 +28,4 @@
url(r'^', include('documents.legacy_urls')),

url(r'^admin/', include(admin.site.urls)),
url(r'', include('social_auth.urls')),


)
]
4 changes: 2 additions & 2 deletions web/dbpatterns/documents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from django.conf import settings
from django.utils.functional import SimpleLazyObject

from pymongo import Connection
from pymongo import MongoClient

_connection = None


def get_connection():
global _connection
if not _connection:
_connection = Connection(
_connection = MongoClient(
host=getattr(settings, 'MONGODB_HOST', None),
port=getattr(settings, 'MONGODB_PORT', None)
)
Expand Down
2 changes: 1 addition & 1 deletion web/dbpatterns/documents/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class SearchInput(forms.TextInput):
def __init__(self, attrs=None, placeholder=None):
super(SearchInput, self).__init__(attrs)

if placeholder not is None:
if placeholder is not None:
self.attrs["placeholder"] = placeholder
Loading