-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of installed askbot dist-packages dirtectory
- Loading branch information
root
committed
Nov 22, 2014
0 parents
commit 013a024
Showing
1,791 changed files
with
585,333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pyo | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
""" | ||
:synopsis: the Django Q&A forum application | ||
Functions in the askbot module perform various | ||
basic actions on behalf of the forum application | ||
""" | ||
import os | ||
import platform | ||
|
||
VERSION = (0, 7, 49) | ||
|
||
#keys are module names used by python imports, | ||
#values - the package qualifier to use for pip | ||
REQUIREMENTS = { | ||
'akismet': 'akismet', | ||
'django': 'django>=1.3.1,<=1.5', | ||
'compressor': 'django-compressor==1.2', | ||
'jinja2': 'Jinja2', | ||
'coffin': 'Coffin>=0.3', | ||
'south': 'South>=0.7.1', | ||
'oauth2': 'oauth2', | ||
'markdown2': 'markdown2', | ||
'html5lib': 'html5lib==0.90', | ||
'keyedcache': 'django-keyedcache', | ||
'threaded_multihost': 'django-threaded-multihost', | ||
'robots': 'django-robots', | ||
'sanction': 'sanction==0.3.1', | ||
'unidecode': 'unidecode', | ||
'django_countries': 'django-countries==1.0.5', | ||
'djcelery': 'django-celery==3.0.11', | ||
'djkombu': 'django-kombu==0.9.4', | ||
'followit': 'django-followit', | ||
'recaptcha_works': 'django-recaptcha-works', | ||
'openid': 'python-openid', | ||
'pystache': 'pystache==0.3.1', | ||
'pytz': 'pytz', | ||
'tinymce': 'django-tinymce==1.5.1b2', | ||
'longerusername': 'longerusername', | ||
'bs4': 'beautifulsoup4', | ||
'picklefield': 'django-picklefield==0.3.0', | ||
} | ||
|
||
if platform.system() != 'Windows': | ||
REQUIREMENTS['lamson'] = 'Lamson' | ||
|
||
#necessary for interoperability of django and coffin | ||
try: | ||
from askbot import patches | ||
from askbot.deployment.assertions import assert_package_compatibility | ||
assert_package_compatibility() | ||
patches.patch_django() | ||
patches.patch_coffin() # must go after django | ||
except ImportError: | ||
pass | ||
|
||
|
||
def get_install_directory(): | ||
"""returns path to directory | ||
where code of the askbot django application | ||
is installed | ||
""" | ||
return os.path.dirname(__file__) | ||
|
||
|
||
def get_path_to(relative_path): | ||
"""returns absolute path to a file | ||
relative to ``askbot`` directory | ||
``relative_path`` must use only forward slashes | ||
and must not start with a slash | ||
""" | ||
root_dir = get_install_directory() | ||
assert(relative_path[0] != 0) | ||
path_bits = relative_path.split('/') | ||
return os.path.join(root_dir, *path_bits) | ||
|
||
|
||
def get_version(): | ||
"""returns version of the askbot app | ||
this version is meaningful for pypi only | ||
""" | ||
return '.'.join([str(subversion) for subversion in VERSION]) | ||
|
||
|
||
def get_database_engine_name(): | ||
"""returns name of the database engine, | ||
independently of the version of django | ||
- for django >=1.2 looks into ``settings.DATABASES['default']``, | ||
(i.e. assumes that askbot uses database named 'default') | ||
, and for django 1.1 and below returns settings.DATABASE_ENGINE | ||
""" | ||
import django | ||
from django.conf import settings as django_settings | ||
major_version = django.VERSION[0] | ||
minor_version = django.VERSION[1] | ||
if major_version == 1: | ||
if minor_version > 1: | ||
return django_settings.DATABASES['default']['ENGINE'] | ||
else: | ||
return django_settings.DATABASE_ENGINE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
:synopsis: connector to standard Django admin interface | ||
To make more models accessible in the Django admin interface, add more classes subclassing ``django.contrib.admin.Model`` | ||
Names of the classes must be like `SomeModelAdmin`, where `SomeModel` must | ||
exactly match name of the model used in the project | ||
""" | ||
from django.contrib import admin | ||
from askbot import models | ||
|
||
class AnonymousQuestionAdmin(admin.ModelAdmin): | ||
"""AnonymousQuestion admin class""" | ||
|
||
class TagAdmin(admin.ModelAdmin): | ||
"""Tag admin class""" | ||
|
||
class VoteAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
class FavoriteQuestionAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
class PostRevisionAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
class AwardAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
class ReputeAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
class ActivityAdmin(admin.ModelAdmin): | ||
""" admin class""" | ||
|
||
admin.site.register(models.Post) | ||
admin.site.register(models.Tag, TagAdmin) | ||
admin.site.register(models.Vote, VoteAdmin) | ||
admin.site.register(models.FavoriteQuestion, FavoriteQuestionAdmin) | ||
admin.site.register(models.PostRevision, PostRevisionAdmin) | ||
admin.site.register(models.Award, AwardAdmin) | ||
admin.site.register(models.Repute, ReputeAdmin) | ||
admin.site.register(models.Activity, ActivityAdmin) | ||
admin.site.register(models.BulkTagSubscription) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""place for the API calls into askbot | ||
at this point most of the useful functions are still | ||
in the askbot.models module, but | ||
api must become a place to manupulate the data in the askbot application | ||
so that other implementations of the data storage could be possible | ||
""" | ||
from django.db.models import Q | ||
from askbot import models | ||
from askbot import const | ||
|
||
def get_info_on_moderation_items(user): | ||
"""returns a dictionary with | ||
counts of new and seen moderation items for a given user | ||
if user is not a moderator or admin, returns None | ||
""" | ||
if user.is_anonymous(): | ||
return None | ||
if not(user.is_moderator() or user.is_administrator()): | ||
return None | ||
|
||
content_types = ( | ||
const.TYPE_ACTIVITY_MARK_OFFENSIVE, | ||
const.TYPE_ACTIVITY_MODERATED_NEW_POST, | ||
const.TYPE_ACTIVITY_MODERATED_POST_EDIT, | ||
) | ||
|
||
messages = models.ActivityAuditStatus.objects.filter( | ||
activity__activity_type__in = content_types, | ||
user = user | ||
) | ||
|
||
seen_count = messages.filter( | ||
status = models.ActivityAuditStatus.STATUS_SEEN | ||
).count() | ||
new_count = messages.filter( | ||
status = models.ActivityAuditStatus.STATUS_NEW | ||
).count() | ||
return { | ||
'seen_count': seen_count, | ||
'new_count': new_count | ||
} | ||
|
||
def get_admin(seed_user_id = None): | ||
"""returns user objects with id == seed_user_id | ||
if the user with that id is not an administrator, | ||
the function will try to find another admin or moderator | ||
who has the smallest user id | ||
if the user is not found, or there are no moderators/admins | ||
User.DoesNotExist will be raised | ||
The reason this function is here and not on a manager of | ||
the user object is because we still patch the django-auth User table | ||
and it's probably better not to patch the manager | ||
""" | ||
|
||
if seed_user_id: | ||
user = models.User.objects.get(id = seed_user_id)#let it raise error here | ||
if user.is_administrator() or user.is_moderator(): | ||
return user | ||
try: | ||
return models.User.objects.filter( | ||
Q(is_superuser=True) | Q(status='m') | ||
).order_by('id')[0] | ||
except IndexError: | ||
raise models.User.DoesNotExist( | ||
"""Please add a moderator or an administrator to the forum first | ||
there don't seem to be any""" | ||
) |
Oops, something went wrong.