Skip to content

Commit

Permalink
Merge pull request #54 from AnjaneyuluBatta505/TestSettings
Browse files Browse the repository at this point in the history
test settings added
  • Loading branch information
chaitu210 committed May 18, 2016
2 parents de04eef + fcceb72 commit e3657be
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ before_script:

# command to run tests
script:
- python manage.py test
- coverage run --source=django_blog_it.posts,django_blog_it.django_blog_it manage.py test
- python test_runner.py test
- coverage run --source=django_blog_it.posts,django_blog_it.django_blog_it test_runner.py test

after_success:
coveralls
21 changes: 21 additions & 0 deletions django_blog_it/django_blog_it/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.conf.urls import url
from .views import *

urlpatterns = [
url(r'^$', admin_login, name='admin_login'),
url(r'^logout/$', admin_logout, name='admin_logout'),
url(r'^blog/$', blog, name='blog'),
url(r'^add/$', blog_add, name='blog_add'),
url(r'^view/(?P<blog_slug>[-\w]+)/$', view_blog, name='view_blog'),
url(r'^delete/(?P<blog_slug>[-\w]+)/$', delete_blog, name='delete_blog'),
url(r'^edit/(?P<blog_slug>[-\w]+)/$', edit_blog, name='edit_blog'),
url(r'^add_category/$', add_category, name='add_category'),
url(r'^category/$', categories, name='categories'),
url(r'^delete_category/(?P<category_slug>[-\w]+)/$', delete_category, name='delete_category'),
url(r'^edit_category/(?P<category_slug>[-\w]+)/$', edit_category, name='edit_category'),

url(r'^bulk_actions_blog/$', bulk_actions_blog, name='bulk_actions_blog'),
url(r'^bulk_actions_category/$', bulk_actions_category, name='bulk_actions_category'),
url(r'upload_photos/$', upload_photos, name='upload_photos'),
url(r'recent_photos/$', recent_photos, name='recent_photos'),
]
5 changes: 2 additions & 3 deletions django_blog_it/django_blog_it/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

admin_required = user_passes_test(lambda user: user.is_active, login_url=reverse('admin_login'))
admin_required = user_passes_test(lambda user: user.is_active, login_url='/')


def active_admin_required(view_func):
decorated_view_func = login_required(admin_required(view_func), login_url=reverse('admin_login'))
decorated_view_func = login_required(admin_required(view_func), login_url='/')
return decorated_view_func


Expand Down Expand Up @@ -516,7 +516,6 @@ def delete_page(request, page_slug):
def bulk_actions_pages(request):
if request.user.is_superuser:
if request.method == 'GET':
print (request.GET)
if 'page_ids[]' in request.GET:
if request.GET.get('action') == 'True':
Page.objects.filter(id__in=request.GET.getlist('page_ids[]')).update(
Expand Down
14 changes: 14 additions & 0 deletions django_blog_it/posts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.conf.urls import url
from .views import *

urlpatterns = [
url(r'^$', index, name='index'),
url(r'^blog/category/(?P<category_slug>[-\w]+)/$', selected_category,
name='selected_category'),
url(r'^blog/tags/(?P<tag_slug>[-\w]+)/$',
selected_tag, name='selected_tag'),
url(r'^blog/(?P<year>\w{0,})/(?P<month>\w{0,})/$',
archive_posts, name='archive_posts'),
url(r'^blog/(?P<blog_slug>[-\w]+)/$',
blog_post_view, name='blog_post_view'),
]
77 changes: 77 additions & 0 deletions django_blog_it/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

SECRET_KEY = '_nc9_+ntllx!ptq5tzh96nn^$a#81#auhrdw#8t#+n0#4ig(lz'

TEMPLATE_LOADERS = (
'django.template.loaders.app_directories.Loader',
)

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',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'django_blog_it.urls'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'simple_pagination',
'django_blog_it.django_blog_it',
'django_blog_it.posts',
)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR + 'sqlite3.db'
}
}

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
],
},

},
]
4 changes: 2 additions & 2 deletions manage.py → test_runner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
import os
import sys

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

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

0 comments on commit e3657be

Please sign in to comment.