Exemple #1
0
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)} )
Exemple #2
0
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 )
Exemple #3
0
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" )
Exemple #4
0
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 )
Exemple #5
0
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} )
Exemple #6
0
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 )
Exemple #7
0
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 ="******"/" )
Exemple #8
0
def users_list( request, context ):
    all_users = Nickname.all().order("-project_count")
    context['all_users'] = all_users
    
    return render_to_response( "users.html", context )