本文整理汇总了Python中bootcamp.feeds.models.Feed类的典型用法代码示例。如果您正苦于以下问题:Python Feed类的具体用法?Python Feed怎么用?Python Feed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Feed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_also_commented_notification
def test_also_commented_notification(self):
post = "A very thoughful comment."
also_commented_count = Feed.get_comments(self.feed).count()
self.feed.comment(user=self.another_user, post=post)
self.user.profile.notify_also_commented(self.feed)
new_also_commented_count = Feed.get_comments(self.feed).count()
assert also_commented_count < new_also_commented_count
示例2: post
def post(request):
last_feed = request.POST.get('last_feed')
user = request.user
csrf_token = unicode(csrf(request)['csrf_token'])
feed = Feed()
feed.user = user
feed.post = request.POST['post']
feed.save()
html = _html_feeds(last_feed, user, csrf_token)
return HttpResponse(html)
示例3: post
def post(request):
last_feed = request.POST.get('last_feed')
user = request.user
csrf_token = (csrf(request)['csrf_token'])
feed = Feed()
feed.user = user
post = request.POST['post']
post = post.strip()
if len(post) > 0:
feed.post = post[:255]
feed.save()
html = _html_feeds(last_feed, user, csrf_token)
return HttpResponse(html)
示例4: post
def post(request):
last_feed = request.POST.get('last_feed')
user = request.user
csrf_token = unicode(csrf(request)['csrf_token'])
feed = Feed()
feed.user = user
post = request.POST['post']
post = post.strip()
if len(post) > 0:
feed.post = post[:255]
feed.save()
tag = request.session.get('TRIBE_TAG')
html = _html_feeds(tag, last_feed, user, csrf_token)
return HttpResponse(html)
示例5: signup
def signup(request):
print request
if request.method == 'POST':
form = SignUpForm(request.POST)
description = request.POST.get('description')
language = request.POST.getlist('language')
area = request.POST.get('area')
gender = request.POST.get('gender')
content = request.POST.get('content')
birth_year_month = request.POST.get('birth_year_month')
birth_year_day = request.POST.get('birth_year_day')
birth_year_year = request.POST.get('birth_year_year')
language_temp = ""
for i in language:language_temp = language_temp + i + ','
print "description : %s " % description
print "language : %s " % language
print "area : %s " % area
print "gender : %s " % gender
print "birth_year_month : %s " % birth_year_month
print "birth_year_day : %s " % birth_year_day
print "birth_year_year : %s " % birth_year_year
birth_day = datetime.datetime(int(birth_year_year), int(birth_year_month), int(birth_year_day), 00, 00, 00)
if not form.is_valid():
return render(request, 'auth/signup.html', {'form': form})
else:
username = form.cleaned_data.get('username')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
User.objects.create_user(username=username, password=password, email=email)
user = authenticate(username=username, password=password)
user.profile.self_introduction = description
user.profile.language = language_temp
user.profile.area = area
user.profile.gender = gender
user.profile.birthday = birth_day
login(request, user)
welcome_post = u'{0} さんがログインしました'.format(user.username, user.username)
feed = Feed(user=user, post=welcome_post)
feed.save()
return redirect('/')
else:
return render(request, 'auth/signup.html', {'form': SignUpForm()})
示例6: load
def load(request):
from_feed = request.GET.get('from_feed')
page = request.GET.get('page')
feed_source = request.GET.get('feed_source')
all_feeds = Feed.get_feeds(from_feed)
if feed_source != 'all':
all_feeds = all_feeds.filter(user__id=feed_source)
paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
try:
feeds = paginator.page(page)
except PageNotAnInteger:
return HttpResponseBadRequest()
except EmptyPage:
feeds = []
html = u''
csrf_token = unicode(csrf(request)['csrf_token'])
for feed in feeds:
html = u'{0}{1}'.format(html,
render_to_string('feeds/partial_feed.html',
{
'feed': feed,
'user': request.user,
'csrf_token': csrf_token
}))
return HttpResponse(html)
示例7: check
def check(request):
last_feed = request.GET.get('last_feed')
feed_source = request.GET.get('feed_source')
feeds = Feed.get_feeds_after(last_feed)
if feed_source != 'all':
feeds = feeds.filter(user__id=feed_source)
count = feeds.count()
return HttpResponse(count)
示例8: signup
def signup(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if not form.is_valid():
return render(request, 'auth/signup.html', {'form': form})
else:
username = form.cleaned_data.get('username')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
User.objects.create_user(username=username, password=password, email=email)
user = authenticate(username=username, password=password)
login(request, user)
welcome_post = u'{0} has joined the network.'.format(user.username, user.username)
feed = Feed(user=user, post=welcome_post)
feed.save()
return redirect('/')
else:
return render(request, 'auth/signup.html', {'form': SignUpForm()})
示例9: update
def update(request):
first_feed = request.GET.get('first_feed')
last_feed = request.GET.get('last_feed')
feeds = Feed.get_feeds().filter(id__range=(last_feed, first_feed))
dump = {}
for feed in feeds:
dump[feed.pk] = {'likes': feed.likes, 'comments': feed.comments}
data = json.dumps(dump)
return HttpResponse(data, mimetype='application/json')
示例10: signup
def signup(request):
if request.method == "POST":
form = SignUpForm(request.POST)
if not form.is_valid():
return render(request, "auth/signup.html", {"form": form})
else:
username = form.cleaned_data.get("username")
email = form.cleaned_data.get("email")
password = form.cleaned_data.get("password")
User.objects.create_user(username=username, password=password, email=email)
user = authenticate(username=username, password=password)
login(request, user)
welcome_post = "{0} has joined the network.".format(user.username, user.username)
feed = Feed(user=user, post=welcome_post)
feed.save()
return redirect("/")
else:
return render(request, "auth/signup.html", {"form": SignUpForm()})
示例11: profile
def profile(request, username):
page_user = User.objects.get(username=username)
all_feeds = Feed.get_feeds().filter(user=page_user)
paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
feeds = paginator.page(1)
from_feed = -1
if feeds:
from_feed = feeds[0].id
return render(
request, "core/profile.html", {"page_user": page_user, "feeds": feeds, "from_feed": from_feed, "page": 1}
)
示例12: _html_feeds
def _html_feeds(last_feed, user, csrf_token):
feeds = Feed.get_feeds_after(last_feed)
html = u''
for feed in feeds:
html = u'{0}{1}'.format(html, render_to_string('feeds/partial_feed.html', {
'feed': feed,
'user': user,
'csrf_token': csrf_token
})
)
return html
示例13: profile
def profile(request, username):
page_user = get_object_or_404(User, username=username)
tag = request.session.get("TRIBE_TAG")
all_feeds = Feed.get_feeds(tag).filter(user=page_user)
paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
feeds = paginator.page(1)
from_feed = -1
if feeds:
from_feed = feeds[0].id
return render(
request, "core/profile.html", {"page_user": page_user, "feeds": feeds, "from_feed": from_feed, "page": 1}
)
示例14: feeds
def feeds(request):
all_feeds = Feed.get_feeds()
paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
feeds = paginator.page(1)
from_feed = -1
if feeds:
from_feed = feeds[0].id
return render(request, 'feeds/feeds.html', {
'feeds': feeds,
'from_feed': from_feed,
'page': 1,
})
示例15: update
def update(request):
first_feed = request.GET.get('first_feed')
last_feed = request.GET.get('last_feed')
feed_source = request.GET.get('feed_source')
feeds = Feed.get_feeds().filter(id__range=(last_feed, first_feed))
if feed_source != 'all':
feeds = feeds.filter(user__id=feed_source)
dump = {}
for feed in feeds:
dump[feed.pk] = {'likes': feed.likes, 'comments': feed.comments}
data = json.dumps(dump)
return HttpResponse(data, content_type='application/json')