コード例 #1
0
ファイル: views.py プロジェクト: bmander/proje
def add_project(request, user):
    
    if request.method=="POST":
        # process form
        
        # fail if the name is blank
        name = request.POST['name'].strip()
        if name == "":
            return HttpResponseRedirect( "?error=the+name+needs+to+contain+letters" )
            
        # make and put project
        project = Project(user=user,name=name,updated=datetime.datetime.now())
        project.put()
        
        # increment project_count
        nickname = Nickname.all().filter("user ="******"includes/project_div.html", {'project':{'name':project.name,'id':project.key().id()}} )
    
    return render_to_response( "add_project.html", {'error':request.GET.get('error',None)} )
コード例 #2
0
ファイル: views.py プロジェクト: bmander/proje
def update_project_counts( request, user ):
    n = 0
    for nickname in Nickname.all():
        nickname.project_count = Project.all().filter("user ="******"Projects counted for %d nicknames"%n )
コード例 #3
0
ファイル: views.py プロジェクト: bmander/proje
def feed(request, nickname):
    nickname = Nickname.all().filter("nickname =", nickname).get()
    
    if nickname is None:
        return HttpResponseNotFound( "No such user" )
        
    scraps = Scrap.all().filter("creator =", nickname.user).order("-created").fetch(50)
    
    return render_to_response( "feed.xml", {'user':nickname.user, 'scraps':scraps}, mimetype="application/rss+xml" )
コード例 #4
0
ファイル: views.py プロジェクト: bmander/proje
def home(request, context, user):
    # if we haven't already created a Nickname for this google account's current nickname, create one
    if Nickname.all().filter("nickname =", user.nickname()).count() == 0:
        Nickname(user=user, nickname=user.nickname()).put()
        
    projects = get_projects_with_scraplists( user )
    
    context['user'] = user
    context['projects'] = projects
    return render_to_response( "home.html", context )
コード例 #5
0
ファイル: views.py プロジェクト: bmander/proje
def welcome(request):
    user = users.get_current_user()
    
    if user:
        enter_url="/"
    else:
        enter_url=users.create_login_url("/")
        
    user_count = Nickname.all().count()
    project_count = Project.all().count()
    
    return render_to_response( "welcome.html", {'enter_url':enter_url, 'user_count':user_count, 'project_count':project_count} )
コード例 #6
0
ファイル: views.py プロジェクト: bmander/proje
def user(request, context, nickname):
    # get a user from the nickname
    nickname = Nickname.all().filter("nickname =", nickname).get()
    
    if nickname is None:
        return HttpResponseNotFound( "No such user" )
        
    projects = get_projects_with_scraplists( nickname.user )
    
    context.update( {'subject_user':nickname.user,'projects':projects} )
    
    # get projects from the user
    return render_to_response( "user.html", context )
コード例 #7
0
ファイル: views.py プロジェクト: bmander/proje
def delete_project( request, user, id ):
    project = Project.get_by_id(int(id))
    
    if project.user != user:
        return HttpResponseForbidden( "<html><body>That doesn't belong to you</body></html>" )
        
    # get nickname of user, to decrement their project_count
    nickname = Nickname.all().filter("user ="******"/" )
コード例 #8
0
ファイル: views.py プロジェクト: bmander/proje
def users_list( request, context ):
    all_users = Nickname.all().order("-project_count")
    context['all_users'] = all_users
    
    return render_to_response( "users.html", context )