Пример #1
0
def tag(request, id):
    args = common_args(request)
    tag = Tag.objects.get(id=id)
    posts = tag.post.all()
    args.update({'posts': posts})
    args.update(csrf(request))
    return render_to_response('tag.html', args)
Пример #2
0
def project(request, id=None):
    project = None
    args = common_args(request)
    if id == '':
        project = Project.objects.all()
    else:
        project = Project.objects.get(id=id)
    print id == ''
    args.update({'project':project})
    if args['user']:
        project_form = get_form(request, ProjectForm, request.user)
        args.update({'project_forms':project_form})
    if id != "" and project.repos:
        repo = project.repos.all()[0]
        args['commits']  = repo.get_commits()
    args.update(csrf(request))
    return render_to_response('project/basic.html', args)
Пример #3
0
def developer_args(request, developer):
    args = common_args(request)
    args.update(csrf(request))
    developer = Developer.objects.get(user=User.objects.get(username=developer))
    #developer = args['developer']
    args.update({
         'developer': developer,
#         'base_template': 'developer/profile_base.html',
         })
    new_providers = settings.AVAILABLE_PROVIDERS
    current_providers = {}
    if request.user.is_authenticated():
        for soc in developer.user.social_auth.all():
            current_providers.update({ soc.provider  : 'providers/%s.html' % soc.provider});
            #if(soc.provider in settings.AVAILABLE_PROVIDERS):
                #new_providers.remove(soc.provider)
        args['new_providers'] = new_providers
        args['current_providers'] = current_providers
    return args
Пример #4
0
def post(request, id):
    args = common_args(request)
    if id == '':
        return redirect('list_posts')
    post = Post.objects.get(id = id)
    if request.POST:
        print request.POST
        try:
            if request.POST['text']:
                    print request.POST
                    form = TagForm(request.POST)
                    if form.is_valid():
                        print 'valid'
                        tag = form.save()
                        print tag
                        post.tags.add(tag)
                        args.update({'result': 'your tag got added'})
                    else:
                        args.update({'result': 'your tag did not validate...'})
        except:
            args.update({'result': 'not a tag'})
            isTag = False
            try:
                if request.POST['url']:
                    form = LinkForm(request.POST)
                    if form.is_valid():
                        link = form.save()
    #                    link.save()
                        post.links.add(link)
                        args.update({'result': 'your link got added'})
                    else:
                        args.update({'result': 'your link did not validate...'})
            except:
                args.update({'result': 'not a link'})
    args.update({'post':post})
    args.update({'tag_form':TagForm()})
    args.update({'link_form':LinkForm()})
    args.update(csrf(request))
    return render_to_response('post/basic.html', args)