Пример #1
0
def category(request, category_title):
    category = get_object_or_404(Category, slug=category_title)
    if request.method == "POST":
        thread = Thread(
            poster=request.user, topic=request.POST["title"], description=request.POST["body"], category=category
        )
        thread.save()
    return render("forum/category", dict({"category": category, "thread_list": category.thread_set.all()}))
Пример #2
0
def edit_post(request, post_title):
    post = get_object_or_404(BlogPost, pk=post_title)
    if not post.author == request.user:
        return HttpResponseRedirect("/blog/"+post_title+"/")
    if request.method == 'POST':
        post.body = request.POST["content"]
        post.save()
        return HttpResponseRedirect("/blog/"+post.slug+"/")
    return render('blog/edit', dict({"post":post}))
Пример #3
0
def edit_profile(request, member, profile):
    if not member==request.user:
        return render('member/profile',dict({'profile':profile}))   
    if request.method == 'POST':
        form = EditProfileForm(request.POST)
        if form.is_valid():
            member.email = form.cleaned_data['email']
            member.first_name = form.cleaned_data['first_name']
            member.last_name = form.cleaned_data['last_name']
            profile.url = form.cleaned_data['url']
            profile.signature = form.cleaned_data['signature']
            member.save()
            profile.save()
        return render('member/edit_profile', dict({'form':form}))

    form = EditProfileForm({'email':member.email, 'first_name':member.first_name, 'last_name':member.last_name, 'url':profile.url, 'signature':profile.signature}, instance=profile)
    if form.is_valid():
        form.save()
    return render('member/edit_profile',dict({'form':form}))    
Пример #4
0
def create_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            import datetime
            category = get_object_or_404( Category, pk = 'Projects' )
            forum_thread = Thread( topic = form.cleaned_data['title'], poster = request.user, category = category, description = "Login to discuss this project.")
            forum_thread.save()
            wiki_page = Page( title = form.cleaned_data['title'] )
            wiki_page.save()
            newproj = Project( title = form.cleaned_data['title'], owner = form.cleaned_data['owner'], last_update = datetime.datetime.now(), status = form.cleaned_data['status'], description = form.cleaned_data['description'],documentation = form.cleaned_data['documentation'],wiki_page = wiki_page,forum_thread = forum_thread)       
            newproj.save()
            return HttpResponseRedirect("/projects/"+newproj.slug+"/")
    form = ProjectForm()
    return render('projects/create', dict(form = form))
Пример #5
0
def create_profile(request):
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            # create user and profile
            new_user = User.objects.create_user(username = form.cleaned_data['username'], email= form.cleaned_data['email'], password = form.cleaned_data['password'])
            new_user.is_staff = False
            new_user.is_active = True
            new_profile = UserProfile.objects.create(user=new_user)
            new_profile.save()
            new_user.save()
            # log the user in
            user = authenticate(username = form.cleaned_data['username'], password = form.cleaned_data['password'])
            login(request, user)
            return profile(request, new_user.username)
    else:
        form = NewUserForm()
    return render('member/create_profile', dict({"form":form}))
Пример #6
0
def view_post(request, post_title):
    post = get_object_or_404(BlogPost, pk = post_title)
    return render('blog/post', dict({"post":post}))
Пример #7
0
def profile(request, username):
    member = get_object_or_404(User, username=username)
    profile = member.get_profile()
    if request.user.is_authenticated(): 
        return edit_profile(request, member, profile)
    return render('member/profile',dict({'profile':profile, 'member':member}))    
Пример #8
0
def edit_page(request, page_title):
    page = get_object_or_404(Page, pk = page_title)
    content = page.content
    return render("wiki/edit", dict({ "page":page }))
Пример #9
0
def index(request):
    latest_posts = BlogPost.objects.all().order_by('-pub_date')[:5]
    return render('blog/index', dict(latest_posts=latest_posts))
Пример #10
0
def index(request):
    return render('home/index')
Пример #11
0
def create_post(request):
    return render('blog/create')
Пример #12
0
def page_history(request, page_title):
    page = get_object_or_404(Page, pk = page_title)
    edits = page.edits.order_by('-pub_date')
    return render("wiki/history", dict({"page":page, "edits":edits}))
Пример #13
0
def index(request):
    category_list = Category.objects.all()
    return render("forum/index", dict({"category_list": category_list}))
Пример #14
0
def create_page(request):
    if request.method == 'POST':
        page = Page( title = request.POST['title'], content = request.POST['content'], last_edit=datetime.datetime.now())
        page.save()
        return HttpResponseRedirect("/wiki/"+page.slug+"/")
    return render("wiki/new")
Пример #15
0
def index(request):
    latest_projects = Project.objects.all().order_by('-last_update')[:5]
    return render('projects/index', dict(latest_projects=latest_projects))
Пример #16
0
def index(request):
    freshest_pages = Page.objects.all().order_by('-last_edit')[:5]
    return render("wiki/index", dict(freshest_pages=freshest_pages))
Пример #17
0
def edit_project(request, project_title):
    project = get_object_or_404( Project, pk = project_title )
    if request.method == 'POST':
        return save_project(request, project_title)
    form =  ProjectForm( instance = project )
    return render('projects/edit_project', dict( form=form ))
Пример #18
0
def view_project(request, project_title):
    project = get_object_or_404( Project, pk = project_title )
    return render('projects/view_project', dict(project=project))
Пример #19
0
def thread(request, category_title, thread_title):
    thread = get_object_or_404(Thread, slug=thread_title)
    if request.method == "POST":
        post = ForumPost(poster=request.user, thread=thread, body=request.POST["body"], isSticky=False)
        post.save()
    return render("forum/thread", dict({"thread": thread, "post_list": thread.forumpost_set.all()}))
Пример #20
0
def view_page(request, page_title):
    page = get_object_or_404(Page, pk = page_title)
    if request.method == 'POST':
        return save_page(request, page_title)
    content = page.content
    return render("wiki/view", dict({"page":page, "content":markdown.markdown(content)}))