def application_settings(request): """The context processor function""" if not request.path.startswith('/' + settings.OPENODE_URL): #todo: this is a really ugly hack, will only work #when openode is installed not at the home page. #this will not work for the #heavy modders of openode, because their custom pages #will not receive the openode settings in the context #to solve this properly we should probably explicitly #add settings to the context per page return {} my_settings = openode_settings.as_dict() my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) my_settings[ 'ALLOWED_UPLOAD_FILE_TYPES'] = settings.OPENODE_ALLOWED_UPLOAD_FILE_TYPES my_settings['OPENODE_URL'] = settings.OPENODE_URL my_settings['STATIC_URL'] = settings.STATIC_URL my_settings['OPENODE_CSS_DEVEL'] = getattr(settings, 'OPENODE_CSS_DEVEL', False) my_settings['DEBUG'] = settings.DEBUG my_settings[ 'FORCE_STATIC_SERVE_WITH_DJANGO'] = settings.FORCE_STATIC_SERVE_WITH_DJANGO my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv my_settings['OPENODE_VERSION'] = openode.get_version() my_settings['LOGIN_URL'] = url_utils.get_login_url() my_settings['USER_REGISTRATION_URL'] = url_utils.get_user_registration_url( ) my_settings['LOGOUT_URL'] = url_utils.get_logout_url() my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url() my_settings['LANGUAGES'] = getattr(settings, 'LANGUAGES', ()) # wysiwyg my_settings["WYSIWYG_SETTING_SIMPLE"] = settings.WYSIWYG_SETTING_SIMPLE my_settings["WYSIWYG_SETTING_COMMENT"] = settings.WYSIWYG_SETTING_COMMENT context = { 'settings': my_settings, 'skin': get_skin(request), 'moderation_items': request.user.get_moderation_items(), 'noscript_url': const.DEPENDENCY_URLS['noscript'], 'THREAD_TYPE_QUESTION': const.THREAD_TYPE_QUESTION, 'THREAD_TYPE_DISCUSSION': const.THREAD_TYPE_DISCUSSION, 'THREAD_TYPE_DOCUMENT': const.THREAD_TYPE_DOCUMENT, } #calculate context needed to list all the organizations def _get_organization_url(organization): """calculates url to the organization based on its id and name""" organization_slug = slugify(organization['name']) return reverse('organization_detail', kwargs={ 'organization_id': organization['id'], 'organization_slug': organization_slug }) return context
def application_settings(request): """The context processor function""" if not request.path.startswith("/" + settings.OPENODE_URL): # todo: this is a really ugly hack, will only work # when openode is installed not at the home page. # this will not work for the # heavy modders of openode, because their custom pages # will not receive the openode settings in the context # to solve this properly we should probably explicitly # add settings to the context per page return {} my_settings = openode_settings.as_dict() my_settings["LANGUAGE_CODE"] = getattr(request, "LANGUAGE_CODE", settings.LANGUAGE_CODE) my_settings["ALLOWED_UPLOAD_FILE_TYPES"] = settings.OPENODE_ALLOWED_UPLOAD_FILE_TYPES my_settings["OPENODE_URL"] = settings.OPENODE_URL my_settings["STATIC_URL"] = settings.STATIC_URL my_settings["OPENODE_CSS_DEVEL"] = getattr(settings, "OPENODE_CSS_DEVEL", False) my_settings["DEBUG"] = settings.DEBUG my_settings["FORCE_STATIC_SERVE_WITH_DJANGO"] = settings.FORCE_STATIC_SERVE_WITH_DJANGO my_settings["USING_RUNSERVER"] = "runserver" in sys.argv my_settings["OPENODE_VERSION"] = openode.get_version() my_settings["LOGIN_URL"] = url_utils.get_login_url() my_settings["USER_REGISTRATION_URL"] = url_utils.get_user_registration_url() my_settings["LOGOUT_URL"] = url_utils.get_logout_url() my_settings["LOGOUT_REDIRECT_URL"] = url_utils.get_logout_redirect_url() my_settings["LANGUAGES"] = getattr(settings, "LANGUAGES", ()) # wysiwyg my_settings["WYSIWYG_SETTING_SIMPLE"] = settings.WYSIWYG_SETTING_SIMPLE my_settings["WYSIWYG_SETTING_COMMENT"] = settings.WYSIWYG_SETTING_COMMENT context = { "settings": my_settings, "skin": get_skin(request), "moderation_items": request.user.get_moderation_items(), "noscript_url": const.DEPENDENCY_URLS["noscript"], "THREAD_TYPE_QUESTION": const.THREAD_TYPE_QUESTION, "THREAD_TYPE_DISCUSSION": const.THREAD_TYPE_DISCUSSION, "THREAD_TYPE_DOCUMENT": const.THREAD_TYPE_DOCUMENT, } # calculate context needed to list all the organizations def _get_organization_url(organization): """calculates url to the organization based on its id and name""" organization_slug = slugify(organization["name"]) return reverse( "organization_detail", kwargs={"organization_id": organization["id"], "organization_slug": organization_slug}, ) return context
def wrapper(request, *args, **kwargs): if openode_settings.USE_AKISMET and openode_settings.AKISMET_API_KEY == "": raise ImproperlyConfigured('You have not set AKISMET_API_KEY') if openode_settings.USE_AKISMET and request.method == "POST": comment = smart_str(request.POST[field]) data = {'user_ip': request.META["REMOTE_ADDR"], 'user_agent': request.environ['HTTP_USER_AGENT'], 'comment_author': smart_str(request.user.username), } if request.user.is_authenticated(): data.update({'comment_author_email': request.user.email}) from akismet import Akismet api = Akismet( openode_settings.AKISMET_API_KEY, smart_str(openode_settings.APP_URL), "Openode/%s" % get_version() ) if api.comment_check(comment, data, build_data=False): logging.debug( 'Spam detected in %s post at: %s', request.user.username, datetime.datetime.now() ) spam_message = _( 'Spam was detected on your post, sorry ' 'for if this is a mistake' ) if request.is_ajax(): return HttpResponseForbidden( spam_message, mimetype="application/json" ) else: request.user.message_set.create(message=spam_message) return HttpResponseRedirect(reverse('index')) return view_func(request, *args, **kwargs)
import ez_setup ez_setup.use_setuptools() from setuptools import setup, find_packages #NOTE: if you want to develop openode #you might want to install django-debug-toolbar as well import openode setup( name = "openode", version = openode.get_version(), # remember to manually set this correctly description = 'Question and Answer forum, like StackOverflow, written in python and Django', packages = find_packages(), author = 'Evgeny.Fadeev', author_email = '*****@*****.**', license = 'GPLv3', keywords = 'forum, community, wiki, Q&A', entry_points = { 'console_scripts': [ 'openode-setup = openode.deployment:openode_setup', ] }, zip_safe = False, url = 'http://openode.org', include_package_data = True, install_requires = openode.REQUIREMENTS.values(), classifiers = [ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Framework :: Django',
import ez_setup ez_setup.use_setuptools() from setuptools import setup, find_packages #NOTE: if you want to develop openode #you might want to install django-debug-toolbar as well import openode setup( name="openode", version=openode.get_version(), # remember to manually set this correctly description= 'Question and Answer forum, like StackOverflow, written in python and Django', packages=find_packages(), author='Evgeny.Fadeev', author_email='*****@*****.**', license='GPLv3', keywords='forum, community, wiki, Q&A', entry_points={ 'console_scripts': [ 'openode-setup = openode.deployment:openode_setup', ] }, zip_safe=False, url='http://openode.org', include_package_data=True, install_requires=openode.REQUIREMENTS.values(), classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment',