예제 #1
0
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
def view_post(request, post_title):
    post = get_object_or_404(BlogPost, pk = post_title)
    return render('blog/post', dict({"post":post}))
예제 #7
0
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
def index(request):
    latest_posts = BlogPost.objects.all().order_by('-pub_date')[:5]
    return render('blog/index', dict(latest_posts=latest_posts))
예제 #10
0
파일: home.py 프로젝트: cubedice/make
def index(request):
    return render('home/index')
예제 #11
0
파일: views.py 프로젝트: cubedice/make
def create_post(request):
    return render('blog/create')
예제 #12
0
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
def index(request):
    category_list = Category.objects.all()
    return render("forum/index", dict({"category_list": category_list}))
예제 #14
0
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
def index(request):
    latest_projects = Project.objects.all().order_by('-last_update')[:5]
    return render('projects/index', dict(latest_projects=latest_projects))
예제 #16
0
파일: views.py 프로젝트: cubedice/make
def index(request):
    freshest_pages = Page.objects.all().order_by('-last_edit')[:5]
    return render("wiki/index", dict(freshest_pages=freshest_pages))
예제 #17
0
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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
파일: views.py 프로젝트: cubedice/make
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)}))