Skip to content

Commit

Permalink
Merge pull request #50 from edx/awais786/BOM-68
Browse files Browse the repository at this point in the history
Awais786/bom 68
  • Loading branch information
awais786 authored Jul 25, 2019
2 parents ba76071 + 4e6910c commit 2dd7d57
Show file tree
Hide file tree
Showing 82 changed files with 354 additions and 161 deletions.
4 changes: 3 additions & 1 deletion django_notify/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import

from django.contrib import admin

from django_notify import models

admin.site.register(models.NotificationType)
admin.site.register(models.Notification)
admin.site.register(models.Settings)
admin.site.register(models.Subscription)
admin.site.register(models.Subscription)
7 changes: 5 additions & 2 deletions django_notify/decorators.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import json
from django.http import HttpResponse

from django.contrib.auth.decorators import login_required
from django.http import HttpResponse

import django_notify


def disable_notify(func):
"""Disable notifications. Example:
Expand Down Expand Up @@ -41,4 +45,3 @@ def wrap(request, *args, **kwargs):
response.write(data)
return response
return wrap

4 changes: 2 additions & 2 deletions django_notify/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

from django.db import models, migrations
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
9 changes: 5 additions & 4 deletions django_notify/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.db.models import Q, Model
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from __future__ import absolute_import

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Model, Q
from django.utils.translation import ugettext_lazy as _

from django_notify import settings

Expand Down
2 changes: 2 additions & 0 deletions django_notify/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import

from django.conf import settings as django_settings

_ = lambda x: x
Expand Down
2 changes: 2 additions & 0 deletions django_notify/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Replace this with more appropriate tests for your application.
"""

from __future__ import absolute_import

from django.test import TestCase


Expand Down
5 changes: 4 additions & 1 deletion django_notify/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from django.conf.urls import url

from django_notify import views

urlpatterns = [
Expand All @@ -14,4 +17,4 @@ def get_pattern(app_name="notify", namespace="notify"):
"""Every url resolution takes place as "notify:view_name".
https://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-reversing-url-namespaces
"""
return urlpatterns, app_name, namespace
return urlpatterns, app_name, namespace
12 changes: 8 additions & 4 deletions django_notify/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-

from django_notify.decorators import json_view, login_required_ajax
from django_notify import models
from __future__ import absolute_import

from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, get_object_or_404
from django.shortcuts import get_object_or_404, redirect

from django_notify import models
from django_notify.decorators import json_view, login_required_ajax


@login_required_ajax
@json_view
Expand Down Expand Up @@ -55,4 +59,4 @@ def mark_read(request, up_to_id, notification_type_id=None):

notifications.update(is_viewed=True)

return {'success': True}
return {'success': True}
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
from __future__ import absolute_import

import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
11 changes: 11 additions & 0 deletions openedx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file describes this Open edX repo, as described in OEP-2:
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0002-bp-repo-metadata.html#specification:

nick: django-wiki
supporting_teams:
- platform-core
tags:
- core
- library
oeps:
oep-7: True
28 changes: 19 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os
from setuptools import setup, find_packages

from setuptools import find_packages, setup
from six.moves import range


def read(fname):
Expand All @@ -17,12 +21,15 @@ def read(fname):
def build_media_pattern(base_folder, file_extension):
return ["%s/%s*.%s" % (base_folder, "*/"*x, file_extension) for x in range(10)]

template_patterns = ( build_media_pattern("templates", "html") +
build_media_pattern("static", "js") +
build_media_pattern("static", "css") +
build_media_pattern("static", "png") +
build_media_pattern("static", "jpeg") +
build_media_pattern("static", "gif"))

template_patterns = (
build_media_pattern("templates", "html") +
build_media_pattern("static", "js") +
build_media_pattern("static", "css") +
build_media_pattern("static", "png") +
build_media_pattern("static", "jpeg") +
build_media_pattern("static", "gif")
)

packages = find_packages()

Expand All @@ -33,7 +40,7 @@ def build_media_pattern(base_folder, file_extension):

setup(
name = "django-wiki",
version="0.0.20",
version="0.0.22",
author="Benjamin Bach",
author_email="[email protected]",
description=("A wiki system written for the Django framework."),
Expand All @@ -55,7 +62,10 @@ def build_media_pattern(base_folder, file_extension):
'Framework :: Django',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
Expand Down
2 changes: 2 additions & 0 deletions testproject/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import absolute_import

import os
import sys

Expand Down
3 changes: 3 additions & 0 deletions testproject/testproject/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from os import path as os_path

PROJECT_PATH = os_path.abspath(os_path.split(__file__)[0])

DEBUG = True
Expand Down
2 changes: 2 additions & 0 deletions testproject/testproject/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import

from django.conf.urls import include, url
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
Expand Down
1 change: 1 addition & 0 deletions testproject/testproject/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.
"""
from __future__ import absolute_import
import os
import sys

Expand Down
2 changes: 2 additions & 0 deletions testproject/vmanage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!virtualenv/bin/python
from __future__ import absolute_import

import os
import sys

Expand Down
19 changes: 14 additions & 5 deletions wiki/admin.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
from __future__ import absolute_import

from django import forms
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from django.utils.translation import ugettext_lazy as _
from mptt.admin import MPTTModelAdmin

from django import forms
import models
import editors
from wiki import editors, models


class ArticleObjectAdmin(GenericTabularInline):
model = models.ArticleForObject
extra = 1
max_num = 1


class ArticleRevisionForm(forms.ModelForm):

class Meta:
Expand All @@ -24,12 +27,14 @@ def __init__(self, *args, **kwargs):
editor = editors.getEditor()
self.fields['content'].widget = editor.get_admin_widget()


class ArticleRevisionAdmin(admin.ModelAdmin):
form = ArticleRevisionForm
class Media:
js = editors.getEditorClass().AdminMedia.js
css = editors.getEditorClass().AdminMedia.css


class ArticleRevisionInline(admin.TabularInline):
model = models.ArticleRevision
form = ArticleRevisionForm
Expand All @@ -41,6 +46,7 @@ class Media:
js = editors.getEditorClass().AdminMedia.js
css = editors.getEditorClass().AdminMedia.css


class ArticleForm(forms.ModelForm):

class Meta:
Expand All @@ -56,10 +62,12 @@ def __init__(self, *args, **kwargs):
self.fields['current_revision'].queryset = models.ArticleRevision.objects.get_empty_query_set()
self.fields['current_revision'].widget = forms.HiddenInput()


class ArticleAdmin(admin.ModelAdmin):
inlines = [ArticleRevisionInline]
form = ArticleForm


class URLPathAdmin(MPTTModelAdmin):
inlines = [ArticleObjectAdmin]
list_filter = ('site', 'articles__article__current_revision__deleted',
Expand All @@ -70,7 +78,8 @@ class URLPathAdmin(MPTTModelAdmin):
def get_created(self, instance):
return instance.article.created
get_created.short_description = _(u'created')



admin.site.register(models.URLPath, URLPathAdmin)
admin.site.register(models.Article, ArticleAdmin)
admin.site.register(models.ArticleRevision, ArticleRevisionAdmin)
admin.site.register(models.ArticleRevision, ArticleRevisionAdmin)
2 changes: 2 additions & 0 deletions wiki/conf/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from django.conf import settings as django_settings
from django.core.urlresolvers import reverse_lazy

Expand Down
4 changes: 3 additions & 1 deletion wiki/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import markdown
from __future__ import absolute_import

import bleach
import markdown


class ArticleMarkdown(markdown.Markdown):
Expand Down
5 changes: 4 additions & 1 deletion wiki/core/diff.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import absolute_import

import difflib


def simple_merge(txt1, txt2):
"""Merges two texts"""
differ = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
diff = differ.compare(txt1.splitlines(1), txt2.splitlines(1))

content = "".join([l[2:] for l in diff])

return content
return content
5 changes: 3 additions & 2 deletions wiki/core/extensions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import absolute_import

from markdown.extensions import Extension

from .processors import AnchorTagProcessor
from wiki.core.processors import AnchorTagProcessor


class AnchorTagExtension(Extension):
"""
Custom extension to register anchor tag processor with Markdown.
"""

def extendMarkdown(self, md, md_globals):
md.treeprocessors.add('AnchorTagProcessor', AnchorTagProcessor(md), '>inline')
7 changes: 5 additions & 2 deletions wiki/core/http.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
from __future__ import absolute_import

import mimetypes
import os
from datetime import datetime

from django.http import HttpResponse
from django.utils.http import http_date
from django.utils import dateformat
from django.utils.http import http_date


def send_file(request, filepath, last_modified=None, filename=None):
fullpath = filepath
Expand Down
3 changes: 3 additions & 0 deletions wiki/core/permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import absolute_import

from wiki.conf import settings


# Article settings.
def can_assign(article, user):
return not user.is_anonymous() and settings.CAN_ASSIGN(article, user)
Expand Down
4 changes: 3 additions & 1 deletion wiki/core/plugins/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import absolute_import

from django.utils.translation import ugettext_lazy as _


"""Base classes for different plugin objects.
* BasePlugin: Create a wiki_plugin.py with a class that inherits from BasePlugin.
Expand Down Expand Up @@ -47,4 +50,3 @@ class PluginSettingsFormMixin(object):

def get_usermessage(self):
pass

Loading

0 comments on commit 2dd7d57

Please sign in to comment.