# -*- coding: utf-8 -*- import datetime import time from sqlalchemy.exceptions import InvalidRequestError, IntegrityError from libs import datetime2timestamp, filter_dict, is_keys_in_dict, smart_unicode from arara import arara_manager from arara import model from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important from arara_thrift.ttypes import * log_method_call = log_method_call_with_source('blacklist_manager') log_method_call_important = log_method_call_with_source_important('blacklist_manager') BLACKLIST_DICT = ['blacklist_username', 'block_article', 'block_message'] BLACKLIST_LIST_DICT = ['id', 'blacklisted_user_nickname', 'blacklisted_user_username', 'blacklisted_date', 'last_modified_date', 'block_article', 'block_message'] class BlacklistManager(arara_manager.ARAraManager): ''' 블랙리스트 처리 관련 클래스 ''' def _get_dict(self, item, whitelist): ''' @type item: model.Blacklist @type whitelist: list<string> @rtype: ttypes.BlacklistInformation '''
#!/usr/bin/python # -*- coding: utf-8 -*- import hashlib import time from sqlalchemy import and_, or_, not_ from sqlalchemy.exc import InvalidRequestError from arara import arara_manager from arara import model from arara_thrift.ttypes import * from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important log_method_call = log_method_call_with_source('file_manager') log_method_call_important = log_method_call_with_source_important( 'file_manager') DANGER_FILE = ('php', 'asp', 'php3', 'php4', 'htaccess', 'js', 'html', 'htm', '.htaccess', 'jsp') class FileManager(arara_manager.ARAraManager): ''' 파일 처리 관련 클래스 ''' def _get_article(self, session, article_id): ''' @type session: model.Session @param session: 현재 사용중인 SQLAlchemy Session @type article_id: int
from sqlalchemy.exc import InvalidRequestError, IntegrityError from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound from sqlalchemy import or_, not_, and_ from libs import datetime2timestamp, filter_dict, is_keys_in_dict, smart_unicode from arara_thrift.ttypes import * from arara import arara_manager from arara import model from arara import ara_memcached from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important, log_method_call_with_source_duration from arara.util import send_mail import etc.arara_settings from etc import arara_settings log_method_call = log_method_call_with_source('member_manager') log_method_call_duration = log_method_call_with_source_duration('member_manager') log_method_call_important = log_method_call_with_source_important('member_manager') import re PROPER_USERNAME_REGEX = re.compile(r'^[a-zA-Z0-9_\-\.]+$') # KAIST E-Mail Address Restriction # 계정명 길이 경계값이 4-20 또는 3-20 으로 알려져 있어서, 1씩 여유를 두었다 PROPER_EMAIL_REGEX = re.compile(r'^[0-9a-zA-Z\_\-\.]{2,21}@kaist.(ac.kr|edu)$') # TODO: non-KAIST E-Mail Address 에 대한 검증도 준비한다 class NoPermission(Exception): pass
from sqlalchemy.exceptions import InvalidRequestError from sqlalchemy.sql import func, select from arara import model from arara.util import require_login from arara.util import ( log_method_call_with_source, log_method_call_with_source_duration, log_method_call_with_source_important, ) from arara.read_status import ReadStatus from arara.read_status.default_backend import ReadStatusManagerDefault from arara_thrift.ttypes import * log_method_call = log_method_call_with_source("read_status_manager_db") log_method_call_duration = log_method_call_with_source_duration("read_status_manager_db") log_method_call_important = log_method_call_with_source_important("read_status_manager_db") class ReadStatusManagerDB(ReadStatusManagerDefault): """ 읽은 글, 통과한글 처리관련 클래스 """ def __init__(self, engine): super(ReadStatusManagerDB, self).__init__(engine) self.read_status = {} def _get_dict(self, item, whitelist=None): item_dict = item.__dict__
import time import logging from sqlalchemy.exc import InvalidRequestError from sqlalchemy import and_, or_, not_ from libs import datetime2timestamp, filter_dict, smart_unicode from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important from arara_thrift.ttypes import * from arara import arara_manager from arara import model from etc.arara_settings import * log_method_call = log_method_call_with_source('search_manager') log_method_call_important = log_method_call_with_source_important('search_manager') READ_ARTICLE_WHITELIST = ('id', 'title', 'contsent', 'last_modified_date', 'deleted', 'blacklisted', 'author_username', 'vote', 'date', 'hit', 'depth', 'root_id', 'is_searchable') SEARCH_ARTICLE_WHITELIST = ('id', 'title', 'heading', 'date', 'last_modified_date', 'reply_count', 'deleted', 'author_username', 'author_nickname', 'author_id', 'positive_vote', 'negative_vote', 'hit', 'content', 'board_name') SEARCH_DICT = ('title', 'content', 'author_nickname', 'author_username', 'date', 'query') class SearchManager(arara_manager.ARAraManager): ''' 게시물 검색 기능을 담당하는 클래스 ''' def _get_dict(self, item, whitelist=None): item_dict = item.__dict__
# -*- coding: utf-8 -*- import logging import traceback from sqlalchemy.exc import InvalidRequestError from sqlalchemy.sql import func, select from arara import model from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_duration, log_method_call_with_source_important from arara.read_status import ReadStatus from arara.read_status.default_backend import ReadStatusManagerDefault from arara_thrift.ttypes import * log_method_call = log_method_call_with_source('read_status_manager_db') log_method_call_duration = log_method_call_with_source_duration('read_status_manager_db') log_method_call_important = log_method_call_with_source_important('read_status_manager_db') class ReadStatusManagerDB(ReadStatusManagerDefault): ''' 읽은 글, 통과한글 처리관련 클래스 ''' def __init__(self, engine): super(ReadStatusManagerDB, self).__init__(engine) self.read_status = {} def _get_dict(self, item, whitelist=None): item_dict = item.__dict__ if whitelist:
# -*- coding: utf-8 -*- import datetime import time from sqlalchemy.exc import InvalidRequestError, IntegrityError from libs import datetime2timestamp, filter_dict, is_keys_in_dict, smart_unicode from arara import arara_manager from arara import model from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important from arara_thrift.ttypes import * log_method_call = log_method_call_with_source('blacklist_manager') log_method_call_important = log_method_call_with_source_important( 'blacklist_manager') BLACKLIST_DICT = ['blacklist_username', 'block_article', 'block_message'] BLACKLIST_LIST_DICT = [ 'id', 'blacklisted_user_nickname', 'blacklisted_user_username', 'blacklisted_date', 'last_modified_date', 'block_article', 'block_message' ] class BlacklistManager(arara_manager.ARAraManager): ''' 블랙리스트 처리 관련 클래스 ''' def _get_dict(self, item, whitelist): '''
# -*- coding: utf-8 -*- from sqlalchemy.exceptions import InvalidRequestError, IntegrityError from libs import datetime2timestamp, filter_dict, smart_unicode from arara import arara_manager from arara import model from arara.model import BOARD_TYPE_NORMAL, BOARD_TYPE_PICTURE, BOARD_TYPE_ANONYMOUS from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important from arara_thrift.ttypes import * log_method_call = log_method_call_with_source('board_manager') log_method_call_important = log_method_call_with_source_important('board_manager') BOARD_MANAGER_WHITELIST = ('board_name', 'board_alias', 'board_description', 'read_only', 'hide', 'id', 'headings', 'order', 'category_id', 'type', 'to_read_level', 'to_write_level') CATEGORY_WHITELIST = ('category_name', 'id', 'order') USER_QUERY_WHITELIST = ('username', 'nickname', 'email', 'signature', 'self_introduction', 'campus', 'last_login_ip', 'last_logout_time') from arara import ara_memcached class BoardManager(arara_manager.ARAraManager): ''' 보드 추가 삭제 및 관리 관련 클래스 ''' def __init__(self, engine): '''
# -*- coding: utf-8 -*- import random from sqlalchemy.exceptions import InvalidRequestError from libs import datetime2timestamp, filter_dict, is_keys_in_dict, timestamp2datetime from arara import arara_manager from arara import model from arara_thrift.ttypes import * from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important log_method_call = log_method_call_with_source('notice_manager') log_method_call_important = log_method_call_with_source_important('notice_manager') NOTICE_QUERY_WHITELIST = ('id', 'content', 'issued_date', 'due_date', 'valid', 'weight') NOTICE_PUBLIC_WHITELIST= ('id', 'content', 'issued_date', 'due_date', 'valid', 'weight') NOTICE_ADD_WHITELIST = ('content','due_date','weight') class NoticeManager(arara_manager.ARAraManager): ''' 배너 및 환영 페이지 처리 관련 클래스 ''' def _get_dict(self, item, whitelist=None): item_dict = item.__dict__ if 'issued_date' in item_dict: item_dict['issued_date'] = datetime2timestamp(item_dict['issued_date']) if 'due_date' in item_dict:
# -*- coding: utf-8 -*- from sqlalchemy.exc import InvalidRequestError from sqlalchemy import or_, not_, and_ from libs import datetime2timestamp, filter_dict, smart_unicode from arara import arara_manager from arara import model from arara_thrift.ttypes import * from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important log_method_call = log_method_call_with_source('messaging_manager') log_method_call_important = log_method_call_with_source_important('messaging_manager') MESSAGE_WHITELIST = ['id', 'from_', 'to', 'from_nickname', 'to_nickname', 'message', 'sent_time', 'read_status', 'blacklisted'] class MessagingManager(arara_manager.ARAraManager): ''' 회원간 쪽지기능등을 담당하는 클래스 ''' def _get_dict(self, item, whitelist=None, blacklist_users=None): ''' @type item: model.Message @param item: dictionary 로 바꿀 객체 (여기서는 메시지) @type whitelist: list<string> @param whitelist: dictionary 에 남아있을 필드의 목록 @type blacklist_users: list<string> @param blacklist_users: Blacklist 로 등록되어 있는 사용자의 목록 @rtype: dict
#!/usr/bin/python # -*- coding: utf-8 -*- import hashlib import time from sqlalchemy import and_, or_, not_ from sqlalchemy.exceptions import InvalidRequestError from arara import arara_manager from arara import model from arara_thrift.ttypes import * from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important log_method_call = log_method_call_with_source('file_manager') log_method_call_important = log_method_call_with_source_important('file_manager') DANGER_FILE = ('php', 'asp', 'php3', 'php4', 'htaccess', 'js', 'html', 'htm', '.htaccess', 'jsp') class FileManager(arara_manager.ARAraManager): ''' 파일 처리 관련 클래스 ''' def _get_article(self, session, article_id): ''' @type session: model.Session @param session: 현재 사용중인 SQLAlchemy Session @type article_id: int @param article_id: 글 번호
import time import logging from sqlalchemy.exc import InvalidRequestError from sqlalchemy import and_, or_, not_ from libs import datetime2timestamp, filter_dict, smart_unicode from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important from arara_thrift.ttypes import * from arara import arara_manager from arara import model from etc.arara_settings import * log_method_call = log_method_call_with_source('search_manager') log_method_call_important = log_method_call_with_source_important( 'search_manager') READ_ARTICLE_WHITELIST = ('id', 'title', 'contsent', 'last_modified_date', 'deleted', 'blacklisted', 'author_username', 'vote', 'date', 'hit', 'depth', 'root_id', 'is_searchable') SEARCH_ARTICLE_WHITELIST = ('id', 'title', 'heading', 'date', 'last_modified_date', 'reply_count', 'deleted', 'author_username', 'author_nickname', 'author_id', 'positive_vote', 'negative_vote', 'hit', 'content', 'board_name') SEARCH_DICT = ('title', 'content', 'author_nickname', 'author_username', 'date', 'query')
from sqlalchemy.exc import InvalidRequestError, IntegrityError from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound from sqlalchemy import or_, not_, and_ from libs import datetime2timestamp, filter_dict, is_keys_in_dict, smart_unicode from arara_thrift.ttypes import * from arara import arara_manager from arara import model from arara import ara_memcached from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important, log_method_call_with_source_duration from arara.util import send_mail import etc.arara_settings from etc import arara_settings log_method_call = log_method_call_with_source('member_manager') log_method_call_duration = log_method_call_with_source_duration( 'member_manager') log_method_call_important = log_method_call_with_source_important( 'member_manager') import re PROPER_USERNAME_REGEX = re.compile(r'^[a-zA-Z0-9_\-\.]+$') # KAIST E-Mail Address Restriction # 계정명 길이 경계값이 4-20 또는 3-20 으로 알려져 있어서, 1씩 여유를 두었다 PROPER_EMAIL_REGEX = re.compile(r'^[0-9a-zA-Z\_\-\.]{2,21}@kaist.(ac.kr|edu)$') # TODO: non-KAIST E-Mail Address 에 대한 검증도 준비한다
# -*- coding: utf-8 -*- import random from sqlalchemy.exc import InvalidRequestError from libs import datetime2timestamp, filter_dict, is_keys_in_dict, timestamp2datetime from arara import arara_manager from arara import model from arara_thrift.ttypes import * from arara.util import require_login from arara.util import log_method_call_with_source, log_method_call_with_source_important log_method_call = log_method_call_with_source('notice_manager') log_method_call_important = log_method_call_with_source_important( 'notice_manager') NOTICE_QUERY_WHITELIST = ('id', 'content', 'issued_date', 'due_date', 'valid', 'weight') NOTICE_PUBLIC_WHITELIST = ('id', 'content', 'issued_date', 'due_date', 'valid', 'weight') NOTICE_ADD_WHITELIST = ('content', 'due_date', 'weight') class NoticeManager(arara_manager.ARAraManager): ''' 배너 및 환영 페이지 처리 관련 클래스 ''' def _get_dict(self, item, whitelist=None): item_dict = item.__dict__