本文整理汇总了Python中warara.check_logged_in函数的典型用法代码示例。如果您正苦于以下问题:Python check_logged_in函数的具体用法?Python check_logged_in怎么用?Python check_logged_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_logged_in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh_weather
def refresh_weather(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
server.bot_manager.refresh_weather_info()
return HttpResponseRedirect('/sysop/')
示例2: rss
def rss(request, mode):
'''
컬렉션에 대한 RSS 파일을 제공한다.
@type request: Django Request
@param request: Request
'''
from django.utils import feedgenerator
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
feed = feedgenerator.Atom1Feed(title = u'ARA', link = COLLECTION_TYPE[mode]['base_url'] + 'rss/', description = COLLECTION_TYPE[mode]['rss_desc'])
page_no = 1
page_length = 20
if mode == 'all':
article_list = server.article_manager.article_list(sess, u"", u"", page_no, page_length, True).hit
elif mode == 'scrap':
article_list = server.article_manager.scrapped_article_list(sess, page_no, page_length).hit
warara.board.views.fake_author(article_list, False)
for article in article_list:
feed.add_item(title='[%s]%s' % (article.board_name, article.title),
link = COLLECTION_TYPE[mode]['base_url'] + '%d/' % article.id,
author_name=article.author_nickname,
pubdate=datetime.datetime.fromtimestamp(article.date),
description=u'author : %s date : %s' % (article.author_nickname, datetime.datetime.fromtimestamp(article.date)))
return HttpResponse(feed.writeString('utf-8'), mimetype=feedgenerator.Atom1Feed.mime_type)
示例3: password_recovery
def password_recovery(request, username, token_code):
sess, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
if r['logged_in'] == True:
raise InvalidOperation("Already logged in!")
if request.method == 'POST':
new_password = request.POST.get('password', '')
new_password_check = request.POST.get('re_password', '')
error_msg = ''
if new_password != new_password_check:
error_msg = 'Passwords are not agree.'
if new_password == '':
error_msg = 'Password cannot be empty.'
if error_msg:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % error_msg)
user_password_dic = {'username':username, 'current_password':u'', 'new_password':new_password}
try:
server.member_manager.modify_password_with_token(UserPasswordInfo(**user_password_dic), token_code)
except InvalidOperation, e:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % e.why)
return HttpResponseRedirect("/")
示例4: index
def index(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
category_list = server.board_manager.get_category_list()
r['category_list'] = category_list + [{'category_name':'None'}]
board_list = server.board_manager.get_board_list()
for board in board_list:
for category in category_list:
if board.category_id == category.id:
board.category_name = category.category_name
r['board_list'] = board_list
bbs_managers_list = []
for board in board_list:
bbs_managers = server.board_manager.get_bbs_managers(board.board_name)
bbs_managers_list.append({'board': board, 'managers': bbs_managers})
r['bbs_managers_list'] = bbs_managers_list
# TODO: 배너를 단순히 나열하기보다는 배너의 날짜 등을 함께 표시하는 것이 어떨까?
banner_list = server.notice_manager.list_banner(sess)
r['banner_list'] = banner_list
rendered = render_to_string('sysop/index.html', r)
return HttpResponse(rendered)
示例5: read
def read(request, board_name, article_id):
'''
주어진 게시판의 주어진 글을 읽어온다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: 읽고자 하는 글이 있는 Board Name
@type article_id: string (int)
@param article_id: 읽고자 하는 글의 번호
'''
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
r['mode'] = 'board'
# 글의 정보를 r 에 저장
_read(request, r, sess, board_name, article_id)
# 화면 하단의 글목록의 정보를 r 에 저장
if filter(lambda x: x.board_name == board_name, r['board_list']): # 게시판 통폐합으로 인해 기존 링크가 깨지는 것을 방지
get_article_list(request, r, 'read')
fake_author(r['article_list'], False)
fake_author(r['article_read_list'])
# 계층형 Reply 구조를 위해 reply를 미리 render
rendered_reply = render_reply(board_name, r['article_read_list'][1:], '/board/%s/' % board_name)
r['rendered_reply'] = rendered_reply
r['article'] = r['article_read_list'][0]
rendered = render_to_string('board/read.html', r)
return HttpResponse(rendered)
示例6: read_root
def read_root(request, board_name, article_id):
'''
주어진 게시판의 주어진 글이 답글인 경우 root글의 주소로 읽어온다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: 읽고자 하는 글이 있는 Board Name
@type article_id: string (int)
@param article_id: 읽고자 하는 글의 번호
'''
server = warara_middleware.get_server() #
sess, r = warara.check_logged_in(request) #
r['mode'] = 'board'
article_list = server.article_manager.read_article(sess, board_name, int(article_id))
root_article_id = article_list[0].root_id
# 글의 정보를 r 에 저장
_read(request, r, sess, board_name, root_article_id)
# 화면 하단의 글목록의 정보를 r 에 저장
get_article_list(request, r, 'read')
fake_author(r['article_read_list'])
fake_author(r['article_list'], False)
rendered = render_to_string('board/read.html', r)
return HttpResponse(rendered)
示例7: send_password_recovery_email
def send_password_recovery_email(request):
sess, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
if r['logged_in'] == True:
raise InvalidOperation("Already logged in!")
if request.method == 'POST':
username = request.POST.get('username_field', '')
email = request.POST.get('email_field', '')
error_msg = ''
if not username:
error_msg = 'Username field is empty.'
if not email:
error_msg = 'Email field is empty.'
if error_msg:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % error_msg)
try:
server.member_manager.send_password_recovery_email(username, email)
resp = "We sent e-mail to your e-mail address. Please check your inbox."
except InvalidOperation, e:
resp = e.why
return HttpResponse('<script>alert("%s"); history.back(); </script>' % resp)
示例8: _reply
def _reply(request, board_name, article_id):
'''
주어진 게시판의 주어진 글에 실제로 reply 를 단다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: reply를 달고자 하는 글이 있는 board name
@type article_id: string (int)
@param article_id: reply를 달고자 하는 글의 번호
@rtype: int
@return: reply 가 달리는 글의 root id
'''
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
reply_dic = {}
reply_dic['content'] = request.POST.get('content', '')
reply_dic['title'] = request.POST.get('title', '')
reply_dic['heading'] = request.POST.get('heading', '') # TODO: HEADING !!
root_id = request.POST.get('root_id', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
reply_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_id = server.article_manager.write_reply(sess, board_name, int(article_id), WrittenArticle(**reply_dic))
#upload file
if request.FILES:
_upload_file(server, sess, article_id, request.FILES)
return root_id
示例9: _relay_fiction_reply
def _relay_fiction_reply(request, board_name, article_id):
'''
이벤트용 임시 답글 함수.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: reply를 달고자 하는 글이 있는 board name
@type article_id: string (int)
@param article_id: reply를 달고자 하는 글의 번호
@rtype: int
@return: reply 가 달리는 글의 root id
'''
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
reply_dic = {}
color = request.POST.get('color', '#000000')
reply_dic['content'] = '<font color=\"' + color + '\">' + request.POST.get('content', '') + '</font>'
reply_dic['title'] = request.POST.get('title', '')
reply_dic['heading'] = request.POST.get('heading', '') # TODO: HEADING !!
root_id = request.POST.get('root_id', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
reply_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_id = server.article_manager.write_reply(sess, board_name, int(article_id), WrittenArticle(**reply_dic))
return root_id
示例10: update
def update(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
blacklist = server.blacklist_manager.get_blacklist(sess)
bl_submit_chooser = request.POST['bl_submit_chooser']
if bl_submit_chooser == "update":
for b in blacklist:
article_bl_key = 'blacklist_article_%s' % b.blacklisted_user_username
if article_bl_key in request.POST:
b.block_article = True
else:
b.block_article = False
message_bl_key = 'blacklist_message_%s' % b.blacklisted_user_username
if message_bl_key in request.POST:
b.block_message = True
else:
b.block_message = False
server.blacklist_manager.modify_blacklist(sess, BlacklistRequest(
blacklisted_user_username = b.blacklisted_user_username,
block_article = b.block_article,
block_message = b.block_message))
if bl_submit_chooser == "delete":
for b in blacklist:
delete_user = request.POST.get('bl_%s_delete' % b.blacklisted_user_username, "")
if delete_user != "":
server.blacklist_manager.delete_blacklist(sess, delete_user)
return HttpResponseRedirect("/blacklist/")
示例11: write_
def write_(request, board_name):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
article_dic = {}
r['url'] = ''.join(['/board/', board_name, '/'])
article_dic['content'] = request.POST.get('text', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
article_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_dic['title'] = request.POST.get('title', '')
article_dic['heading'] = request.POST.get('heading', '') # Heading !!!
if request.POST.get('write_type', 0) == 'modify':
article_no = request.POST.get('article_no', 0)
article_id = server.article_manager.modify_article(sess, board_name, int(article_no), WrittenArticle(**article_dic))
delete_file = request.POST.get('delete_file', 0) #delete_file
if delete_file:
delete_file = delete_file[1:]
delete_file = delete_file.split('&')
for file_id in delete_file:
file = server.file_manager.delete_file(sess, int(article_no), int(file_id))
os.remove("%s/%s/%s" % (FILE_DIR, file.file_path, file.saved_filename))
else:
article_id = server.article_manager.write_article(sess, board_name, WrittenArticle(**article_dic))
#upload file
if request.FILES:
_upload_file(server, sess, article_id, request.FILES)
if request.POST.get('write_type', 0) == 'modify':
return HttpResponseRedirect('/board/%s/%s#%s' % (board_name, request.POST.get('root_id', article_id), article_id))
else:
return HttpResponseRedirect('/board/%s/%s' % (board_name, str(article_id)))
示例12: delete
def delete(request):
if request.method == 'POST':
username = request.POST['username']
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
server.blacklist_manager.delete_blacklist(sess, username)
return HttpResponseRedirect("/blacklist/")
示例13: count_new_message
def count_new_message(request):
server = warara_middleware.get_server()
sess, _ = warara.check_logged_in(request)
try:
result = server.messaging_manager.get_unread_message_count(sess)
return HttpResponse(str(result))
except:
return HttpResponse("0")
示例14: agreement
def agreement(request):
sess, r = warara.check_logged_in(request)
if r['logged_in'] == True:
raise InvalidOperation("Already logged in!")
else:
rendered = render_to_string('account/register_agreement.html')
return HttpResponse(rendered)
示例15: account
def account(request):
session_key, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
account = server.member_manager.get_info(session_key)
account.last_logout_time = timestamp2datetime(account.last_logout_time)
account.logged_in = True
rendered = render_to_string('account/myaccount_frame.html', account.__dict__)
return HttpResponse(rendered)