本文整理汇总了Python中swapleaf.helper.common.get_user_login_object函数的典型用法代码示例。如果您正苦于以下问题:Python get_user_login_object函数的具体用法?Python get_user_login_object怎么用?Python get_user_login_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_user_login_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: buy_book_add_item_process
def buy_book_add_item_process(request,book_isbn):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
try:
book = None
if len(book_isbn) == 10:
books = Book.objects.filter(isbn10=book_isbn)
if len(books) != 0:
book = books[0]
elif len(book_isbn) == 13:
books = Book.objects.filter(isbn13=book_isbn)
if len(books) != 0:
book = books[0]
else:
return HttpResponseRedirect("/book/buy/error")
alert_email = True
if 'alert_email' in request.session:
if request.session['alert_email'] == "0":
alert_email = False
book_buying_list = BookBuying.objects.filter(book=book)
book_buying = None
if len(book_buying_list) == 0:
book_buying = BookBuying.objects.create(book=book)
else:
book_buying = book_buying_list[0]
book_buying.alert_email = alert_email
book_buying.save()
user_login.get_profile().buy_book.add(book_buying)
user_login.get_profile().save()
return HttpResponseRedirect("/")
except Book.DoesNotExist:
return HttpResponseRedirect("/book/buy/error")
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:32,代码来源:views.py
示例2: buy_book_search_isbn
def buy_book_search_isbn(request,book_isbn):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
books = get_book_by_isbn(book_isbn)
if len(books) == 0:
return HttpResponseRedirect('/book/buy/search/not_found')
else:
# print books
# listed_books = convert_queryset_to_list(BookTransaction.objects.filter(book=books[0]).exclude(seller=user_login))
# print listed_books
# return render_to_response(
# "app/book/page/buy/buy_book_listed.html",
# {
# 'user_login': user_login,
# 'new_notify': new_notify,
# 'listed_books': listed_books
# }
# ,context_instance=RequestContext(request))
return render_to_response(
"app/book/page/buy/buy_search.html",
{
'user_login': user_login,
'new_notify': new_notify,
'books': books,
#'book_sellings': book_sellings
}
,context_instance=RequestContext(request))
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:27,代码来源:views.py
示例3: decline_partner
def decline_partner(request,username,notify_id):
user_add_request = User.objects.get(username=username)
user_receive_request = get_user_login_object(request)
fr = FriendshipRequest.objects.filter(from_user=user_add_request, to_user=user_receive_request, accepted=False)
if len(fr) != 0:
fr[0].decline()
n = Notify.objects.get(pk=notify_id)
n.notify_type = 'invite_partner_response_decline'
new_content = render_to_string(NOTIFY_SNIPPET_TEMPLATE['invite_partner_response_decline'],
{
'username': user_add_request.username,
'first_name': user_add_request.first_name ,
'last_name': user_add_request.last_name,
})
n.content = new_content
n.save()
return simplejson.dumps({
'notify_id': notify_id,
'new_content': new_content,
'username':username,
'firstname': user_add_request.first_name,
'lastname': user_add_request.last_name,
'reload':'False'
})
else:
return simplejson.dumps({'reload':'True'})
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:26,代码来源:ajax.py
示例4: main_view
def main_view(request):
message = handle_request_get_message(request)
#autocomplete_data = get_autocomplete_data(request)
new_notify = get_new_notify(request)
#print autocomplete_data
user_login = get_user_login_object(request)
book_sell = BookTransaction.objects.filter(seller=user_login,transaction_type='1')
all_book_sell = BookTransaction.objects.all()
book_trade_give= BookTransaction.objects.filter(seller=user_login,transaction_type='2')
#new_offer = Offer.objects.filter(user_receive=user_login,view_status='new')
#all_offer = Offer.objects.filter(user_receive=user_login)
#transaction_status = get_transaction_status(request)
return render_to_response(
"app/main/page/index.html",
{
'message': message,
#'autocomplete_data': autocomplete_data,
'new_notify': new_notify,
'user_login': user_login,
'book_sell': book_sell,
'all_book_sell': all_book_sell,
'book_trade_give': book_trade_give,
#'new_offer': new_offer,
#'all_offer': all_offer,
#'transaction_status': transaction_status
},
context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:28,代码来源:views.py
示例5: buy_book_search_title_author
def buy_book_search_title_author(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
title,author = "",""
if 'title' in request.session:
title = request.session['title']
if 'author' in request.session:
author = request.session['author']
books = []
if len(title) != 0 and len(author) != 0:
books = get_book_by_title_and_author(title,author)
else:
if len(title) != 0:
books = get_book_by_title(title)
elif len(author) != 0:
books = get_book_by_author(author)
#book_sellings = BookTransaction.objects.filter(transaction_type='1')
return render_to_response(
"app/book/page/buy/buy_search.html",
{
'user_login': user_login,
'new_notify': new_notify,
'books': books,
#'book_sellings': book_sellings
}
,context_instance=RequestContext(request))
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:26,代码来源:views.py
示例6: partner_book_available
def partner_book_available(request,username):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
partner = get_object_or_404(User,username=username)
book_sell_trade = BookTransaction.objects.filter(seller=partner)
if 'sort' in request.GET:
if request.GET['sort'] == 'condition':
book_sell_trade = BookTransaction.objects.filter(seller=partner).order_by('condition')
elif request.GET['sort'] == 'post_time':
book_sell_trade = BookTransaction.objects.filter(seller=partner).order_by('-post_time')
elif request.GET['sort'] == 'title':
list_book_sell_trade = BookTransaction.objects.filter(seller=partner)
list_title = {}
for book_sell_trade in list_book_sell_trade:
list_title[book_sell_trade] = book_sell_trade.book.title
book_sell_trade = sorted(list_title, key=list_title.get)
else:
list_book_sell_trade = BookTransaction.objects.filter(seller=partner)
list_author = {}
for book_sell_trade in list_book_sell_trade:
list_author[book_sell_trade] = book_sell_trade.book.author
book_sell_trade = sorted(list_author, key=list_author.get)
return render_to_response(
"app/partner/page/partner_book_available.html",
{
'user_login': user_login,
'new_notify': new_notify,
'partner': partner,
'book_sell_trade': book_sell_trade
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:32,代码来源:views.py
示例7: partner_book_match
def partner_book_match(request,username):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
partner = get_object_or_404(User,username=username)
user_login_transaction_book = BookTransaction.objects.filter(seller=user_login)
partner_transaction_book = BookTransaction.objects.filter(seller=partner)
books_sell_trade = []
books_buy = []
# Get all the book the user_login want to buy and the partner want to sell/trade
for book_transaction in partner_transaction_book:
for book_buying in user_login.get_profile().buy_book.all():
if book_transaction.book == book_buying.book:
books_sell_trade.append(book_transaction)
# Get all the book the user_login want to sell/trade and the partner want to buy
for book_transaction in user_login_transaction_book:
for book_buying in partner.get_profile().buy_book.all():
if book_transaction.book == book_buying.book:
books_buy.append(book_transaction)
return render_to_response(
"app/partner/page/partner_match.html",
{
'user_login': user_login,
'new_notify': new_notify,
'partner': partner,
"books_buy": remove_duplicate_object(books_buy),
'books_sell_trade': remove_duplicate_object(books_sell_trade)
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:33,代码来源:views.py
示例8: offer_price_form
def offer_price_form(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
# Clear session
if "alert_email" in request.session:
del request.session['alert_email']
if "title" in request.session:
del request.session['title']
if "author" in request.session:
del request.session['author']
if "school_id" in request.session:
del request.session['school_id']
if "course_number" in request.session:
del request.session['course_number']
if "transaction_id" not in request.GET:
return HttpResponseRedirect("/")
else:
try:
transaction_id = request.GET['transaction_id']
transaction = BookTransaction.objects.get(transaction_id=transaction_id)
return render_to_response(
"app/offer/page/offer_form_price.html",
{
"user_login": user_login,
"new_notify": new_notify,
"transaction": transaction,
}
,context_instance=RequestContext(request)
)
except:
return HttpResponseRedirect('/offer/error/')
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:31,代码来源:views.py
示例9: offer_time_location_form
def offer_time_location_form(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
if "transaction_id" not in request.GET:
return HttpResponseRedirect("/")
else:
try:
transaction_id = request.GET['transaction_id']
offer_id = request.GET['offer_id']
notify_id = request.GET['notify_id']
transaction = BookTransaction.objects.get(transaction_id=transaction_id)
offer = Offer.objects.get(pk=offer_id)
notify = Notify.objects.get(pk=notify_id)
return render_to_response(
"app/offer/page/offer_form_time_location.html",
{
"user_login": user_login,
"new_notify": new_notify,
"transaction": transaction,
'offer': offer,
'notify': notify,
}
,context_instance=RequestContext(request)
)
except:
return HttpResponseRedirect('/offer/error/')
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:26,代码来源:views.py
示例10: counter_offer_price_check
def counter_offer_price_check(request):
if "max_offer_id" not in request.GET:
return HttpResponseRedirect("/")
else:
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
max_offer_id = request.GET['max_offer_id']
max_offer = Offer.objects.get(pk=max_offer_id)
counter_price = request.session['counter_price']
message = request.session['message']
transaction_id = request.session['transaction_id']
offer_id = request.session['offer_id']
user_receive = Offer.objects.get(pk=offer_id).user_offer
return render_to_response(
"app/offer/page/counter_offer_price_check.html",
{
'user_login': user_login,
'new_notify': new_notify,
'max_offer': max_offer,
'offer_id': offer_id,
'message': message,
'transaction_id': transaction_id,
'counter_price': counter_price,
'user_receive': user_receive
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:27,代码来源:views.py
示例11: partner_of_partner_match
def partner_of_partner_match(request,username):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
partner = get_object_or_404(User,username=username)
partner_match_data = []
partners = user_login.get_profile().partners.all()
for user1 in partners:
for user2 in partners:
if user1 != user2:
partner_match_data += get_partner_match_value(user1,user2)
return render_to_response(
"app/partner/page/partner_of_partner_match.html",
{
'user_login': user_login,
'new_notify': new_notify,
'partner': partner,
'partner_match_data': remove_duplicate_object(partner_match_data)
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:23,代码来源:views.py
示例12: trade_give_book_process
def trade_give_book_process(request):
user_login = get_user_login_object(request)
#try:
book = Book.objects.get(isbn10=request.session['book_isbn'])
condition = request.session['book_condition']
alert_email = bool(int(request.session['alert_email']))
book_trade_give = BookTransaction.objects.create(transaction_id=uuid.uuid1(),book=book,seller=user_login,condition=condition,transaction_type='2',alert_email=alert_email,price=0.00)
#book_trade_give.transaction_id = uuid.uuid1()
if len(request.session['course_number']) != 0:
institution = user_login.institution_set.all()[0]
course = None
try:
course = Course.objects.get(institution=institution,course_number=request.session['course_number'])
if book not in course.course_book.all():
course.course_book.add(book)
course.save()
except Course.DoesNotExist:
course = Course.objects.create(institution=institution,course_number=request.session['course_number'])
course.course_book.add(book)
course.save()
book_trade_give.course = course
book_trade_give.save()
if "book_condition" in request.session:
del request.session['book_condition']
if "alert_email" in request.session:
del request.session['alert_email']
if "book_isbn" in request.session:
del request.session['book_isbn']
if "course_number" in request.session:
del request.session['course_number']
return HttpResponseRedirect("/")
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:31,代码来源:views.py
示例13: buy_book_search_course_listed
def buy_book_search_course_listed(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
course_number = None
school = None
if "course_number" in request.GET:
course_number = request.GET['course_number']
if 'school_id' in request.GET:
school_id = request.GET['school_id']
books = get_book_by_course(request,course_number,school_id)
if len(books) == 0:
return HttpResponseRedirect("/book/buy/search/not_found")
else:
listed_books = []
for book in books:
listed = convert_queryset_to_list(BookTransaction.objects.filter(book=book).exclude(seller=user_login))
listed_books = listed_books + listed
return render_to_response(
"app/book/page/buy/buy_book_listed.html",
{
'user_login': user_login,
'new_notify': new_notify,
'listed_books': remove_duplicate_object(listed_books)
}
,context_instance=RequestContext(request))
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:25,代码来源:views.py
示例14: sell_book_confirm
def sell_book_confirm(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
if 'isbn' in request.GET:
try:
isbn = request.GET['isbn'].replace(" ","")
book = None
if len(isbn) == 10:
book = Book.objects.get(isbn10=isbn)
elif len(isbn) == 13:
book = Book.objects.get(isbn13=isbn)
else:
return HttpResponseRedirect('book/sell/error')
request.session['book_isbn'] = book.isbn10
course_number = None
if 'course_number' in request.session:
course_number = request.session['course_number']
return render_to_response(
"app/book/page/sell/sell_confirm.html",
{
'user_login': user_login,
'new_notify': new_notify,
'book': book,
'book_price': request.session['book_price'],
'book_condition': request.session['book_condition'],
'course_number': course_number
}
,context_instance=RequestContext(request))
except Book.DoesNotExist:
return HttpResponseRedirect('book/sell/error')
else:
return HttpResponseRedirect('/book/sell/')
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:32,代码来源:views.py
示例15: buy_book_form
def buy_book_form(request):
new_notify = get_new_notify(request)
user_login = get_user_login_object(request)
return render_to_response(
"app/book/page/buy/buy_form.html",
{
'user_login': user_login,
'new_notify': new_notify
}
,context_instance=RequestContext(request))
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:10,代码来源:views.py
示例16: buy_book_search_not_found
def buy_book_search_not_found(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
return render_to_response(
"app/book/page/buy/buy_search_not_found.html",
{
'user_login': user_login,
'new_notify': new_notify,
}
,context_instance=RequestContext(request))
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:10,代码来源:views.py
示例17: buy_book_available_author_process
def buy_book_available_author_process(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
available_book_author = ""
if "available_book_author" in request.GET:
available_book_author = request.GET['available_book_author']
available_book_author = BookAvailableAuthor.objects.create(author=available_book_author)
available_book_author.save()
user_login.get_profile().available_book_author.add(available_book_author)
return HttpResponseRedirect("/")
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:10,代码来源:views.py
示例18: trade_give_book_error
def trade_give_book_error(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
return render_to_response(
"app/book/page/trade_give/trade_give_error.html",
{
"user_login": user_login,
"new_notify": new_notify
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:11,代码来源:views.py
示例19: offer_time_location_success
def offer_time_location_success(request):
user_login = get_user_login_object(request)
new_notify = get_new_notify(request)
return render_to_response(
"app/offer/page/offer_time_location_success.html",
{
"user_login": user_login,
"new_notify": new_notify
}
,context_instance=RequestContext(request)
)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:11,代码来源:views.py
示例20: get_people_by_name
def get_people_by_name(request,query):
user_login = get_user_login_object(request)
author_words = query.split()
result = []
for word in author_words:
if word.lower() not in IGNORE_WORDS:
users1 = convert_queryset_to_list(User.objects.filter(first_name__icontains=word).exclude(pk=1).exclude(pk=user_login.pk))
users2 = convert_queryset_to_list(User.objects.filter(last_name__icontains=word).exclude(pk=1).exclude(pk=user_login.pk))
users = users1 + users2
result = result + users
return remove_duplicate_object(result)
开发者ID:dtn1712,项目名称:Swapleaf,代码行数:11,代码来源:account.py
注:本文中的swapleaf.helper.common.get_user_login_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论