当前位置: 首页>>代码示例>>Python>>正文


Python Feed.save方法代码示例

本文整理汇总了Python中bootcamp.feeds.models.Feed.save方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.save方法的具体用法?Python Feed.save怎么用?Python Feed.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bootcamp.feeds.models.Feed的用法示例。


在下文中一共展示了Feed.save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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)
开发者ID:lucasmg,项目名称:bootcamp,代码行数:12,代码来源:views.py

示例2: post

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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)
开发者ID:ngaurav,项目名称:aadhaar,代码行数:15,代码来源:views.py

示例3: post

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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)
开发者ID:Yihen,项目名称:ibootcamp,代码行数:16,代码来源:views.py

示例4: signup

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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()})
开发者ID:namkim,项目名称:bootcamp,代码行数:50,代码来源:views.py

示例5: signup

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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()})
开发者ID:AVD087,项目名称:bootcamp,代码行数:20,代码来源:views.py

示例6: signup

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
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()})
开发者ID:KathrinWelzel,项目名称:Wedding,代码行数:20,代码来源:views.py

示例7: execute_upload

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import save [as 别名]
    def execute_upload(self,request):
                import uuid
                form = self.form_class(request.POST, request.FILES)
                print request.FILES['file']
                if  form.is_valid():
                    print request.FILES['file']
                    resp = self.handle_uploaded_file(request.FILES['file'])
                    if resp['score'] < 100 :
                        button_type = 'btn-warning'
                    else:
                        button_type = 'btn-success'
                    self.uuid_index  = str(uuid.uuid4())


                    resp['score']= random.randint(1, 100)

                    model = Algorithm

                    run_rank = model.objects.filter(rating__gt=int(resp['score'])).order_by('ranking')
                    if len(run_rank) > 0:
                        rankobj = run_rank.last()
                        rank = rankobj.ranking + 1

                    else:
                        rank = 1

                    run_rank_low = model.objects.filter(rating__lte=int(resp['score']))
                    if len(run_rank_low) > 0 :
                        for i in run_rank_low:
                            i.ranking += 1
                            i.save()

                    else:
                        pass

                    
                   

                    b = Algorithm(run_id= self.uuid_index, name=request.user.username, user=request.user, ranking = rank, rating=resp['score'], button = button_type, time= resp['duration'], cpu=18)
                    b.save()
                    job_post = u'{0} has sent a job score: {1} rank: {2} :'.format(request.user.username,resp['score'], rank)
                    
                    resp = model.objects.all().order_by('ranking')
                    values = resp.values('run_id')
                    
                    for ind, item  in enumerate(values) :
                        if (item['run_id']) == self.uuid_index :
                            paging =  divmod(ind, 5)[0]

                    feed = Feed(user=request.user, post=job_post, job_link='/leaderboard?q=foo&flop=flip&page='+str(paging+1))
                    feed.save()


                    #request.user.profile.notify_job_done(b)      
                    

                    like = Activity(activity_type=Activity.RUN_PROCESSED, feed=feed.pk, user=request.user)
                    like.save()

                    user = request.user
                    user.profile.notify_liked_bis(feed)
                    

                    return paging
开发者ID:echopen,项目名称:kit-soft,代码行数:66,代码来源:views.py


注:本文中的bootcamp.feeds.models.Feed.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。