本文整理汇总了Python中warara.check_logged_in函数的典型用法代码示例。如果您正苦于以下问题:Python check_logged_in函数的具体用法?Python check_logged_in怎么用?Python check_logged_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_logged_in函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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/')
开发者ID:hodduc,项目名称:arara,代码行数:7,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:33,代码来源:views.py
示例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("/")
开发者ID:hodduc,项目名称:arara,代码行数:25,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:28,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:33,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:25,代码来源:views.py
示例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
开发者ID:hodduc,项目名称:arara,代码行数:32,代码来源:views.py
示例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
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例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/")
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例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)))
开发者ID:hodduc,项目名称:arara,代码行数:34,代码来源:views.py
示例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/")
开发者ID:hodduc,项目名称:arara,代码行数:7,代码来源:views.py
示例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")
开发者ID:hodduc,项目名称:arara,代码行数:8,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:8,代码来源:views.py
示例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)
开发者ID:hodduc,项目名称:arara,代码行数:9,代码来源:views.py
示例16: unscrap
def unscrap(request, board_name, root_id, article_no):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
try:
server.article_manager.unscrap_article(sess, int(article_no))
response = HttpResponse("OK")
except InvalidOperation, e:
response = HttpResponse("NOT_SCRAPPED")
开发者ID:hodduc,项目名称:arara,代码行数:9,代码来源:views.py
示例17: destroy
def destroy(request, board_name, root_id, article_no):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
server.article_manager.destroy_article(sess, board_name, int(article_no))
# XXX 2010.05.14.
# 글을 destroy하였으므로 해당 보드로 돌아간다.
# 추후에는 pageno 정보를 이용하도록 수정하는 게 좋겠다.
# 어차피 지금은 SYSOP 이 아니면 이 작업을 할 수 없지만.
return HttpResponseRedirect('/board/%s/' % board_name)
开发者ID:hodduc,项目名称:arara,代码行数:9,代码来源:views.py
示例18: main
def main(request):
server = warara_middleware.get_server()
sess, ctx = warara.check_logged_in(request)
# TODO: rename all 'r' variables to 'ctx' that means 'context'.
# Set username if user is guest
if ctx['username'] == '':
ctx['username'] = 'Guest'
# Get the today best list
ret = cache.get('today_best_list')
if not ret:
ret = server.article_manager.get_today_best_list(5)
for item in ret:
item.date = datetime.datetime.fromtimestamp(item.date)
cache.set('today_best_list', ret, 60)
# TODO: Change the key 'todays_best_list' to 'today_best_list'
# in both here and Template file.
ctx['todays_best_list'] = enumerate(ret)
# Get the weekly-best list
ret = cache.get('weekly_best_list')
if not ret:
ret = server.article_manager.get_weekly_best_list(5)
for item in ret:
item.date = datetime.datetime.fromtimestamp(item.date)
cache.set('weekly_best_list', ret, 60)
ctx['weekly_best_list'] = enumerate(ret)
# Get recent article list of boards
ctx['recent_articles'] = OrderedDict()
for board in MAIN_BOARDS:
try:
ctx['recent_articles'][board] = server.article_manager.recent_article_list(board)
except InvalidOperation:
pass
# Get messages for the current user
if ctx['logged_in']:
unread_message_count = server.messaging_manager.get_unread_message_count(sess)
if unread_message_count > 0:
ctx['new_message'] = True
else:
ctx['new_message'] = False
# Get banner
try:
ctx['banner'] = server.notice_manager.get_banner()
ctx['has_banner'] = True
except InvalidOperation:
ctx['has_banner'] = False
# Ksearch
ctx['KSEARCH_ENABLED'] = KSEARCH_ENABLED
rendered = render_to_string('main.html', ctx)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:56,代码来源:views.py
示例19: list
def list(request, board_name):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
r['mode'] = 'board'
r['board_name'] = board_name
get_article_list(request, r, 'list')
fake_author(r['article_list'], False)
rendered = render_to_string('board/list.html', r)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:10,代码来源:views.py
示例20: list
def list(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
# board_name 이 없기 때문에 사용한 Hack.
r['board_name'] = u'All Articles'
r['mode'] = 'all'
warara.mobile.board.views.get_article_list(request, r, 'total_list')
fake_author(r['article_list'], False)
rendered = render_to_string('mobile/board/list.html', r)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:11,代码来源:views.py
注:本文中的warara.check_logged_in函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论