Esempio n. 1
0
def showactivity(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    activity = Activity.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = activity
                reply.is_active = True
                reply.save()
                activity.clicks = topic.clicks - 1
                activity.save()
                return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/activity/' + str(turl_number) + '/')
            
        
    else:
        reply_form = NewReplyForm()
        activity.clicks = activity.clicks + 1
        activity.save()
        return render_to_response('corporation/activity_corporation.html', {'corporation':corporation, 'current_user':request.user, 'reply_form':reply_form, 'activity':activity, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Esempio n. 2
0
def showactivity(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    activity = Activity.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user,
                                          corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = activity
                reply.is_active = True
                reply.save()
                activity.clicks = topic.clicks - 1
                activity.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/activity/' +
                                            str(turl_number) + '/')

    else:
        reply_form = NewReplyForm()
        activity.clicks = activity.clicks + 1
        activity.save()
        return render_to_response('corporation/activity_corporation.html', {
            'corporation': corporation,
            'current_user': request.user,
            'reply_form': reply_form,
            'activity': activity,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Esempio n. 3
0
def showmail(request, url_number):
    mail = Sitemail.objects(url_number=url_number).get()
    if request.user in [a.target for a in mail.creator]:
        mail.is_readed = True
        mail.save()

    if request.method == "POST":
        form = NewReplyForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            reply = Reply(content=content)
            sscard = S_S_Card.objects.get_or_create(
                user=request.user, target=mail.creator[0].user)
            reply.creator = sscard[0]
            reply.creat_time = datetime.datetime.now()
            reply.target = mail
            reply.is_active = True
            reply.save()
            return HttpResponseRedirect('')

    else:
        return render_to_response('sitemail/showmail.html', {
            'mail': mail,
            'STATIC_URL': STATIC_URL,
            'current_user': request.user
        },
                                  context_instance=RequestContext(request))
Esempio n. 4
0
def showmail(request, url_number):
    mail = Sitemail.objects(url_number=url_number).get()
    if request.user in [a.target for a in mail.creator]:
        mail.is_readed = True
        mail.save()

    if request.method == "POST":
        form = NewReplyForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data["content"]
            reply = Reply(content=content)
            sscard = S_S_Card.objects.get_or_create(user=request.user, target=mail.creator[0].user)
            reply.creator = sscard[0]
            reply.creat_time = datetime.datetime.now()
            reply.target = mail
            reply.is_active = True
            reply.save()
            return HttpResponseRedirect("")

    else:
        return render_to_response(
            "sitemail/showmail.html",
            {"mail": mail, "STATIC_URL": STATIC_URL, "current_user": request.user},
            context_instance=RequestContext(request),
        )
Esempio n. 5
0
def showtopic(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user,
                                          corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = topic
                reply.is_active = True
                reply.save()
                topic.update_author = request.user
                topic.update_time = datetime.datetime.now()
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/topic/' +
                                            str(turl_number) + '/')

        if "modify" in request.POST:
            modify_form = ModifyTopicForm(request.POST)
            if modify_form.is_valid():
                content = modify_form.cleaned_data['content']
                topic.content = content
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/topic/' +
                                            str(turl_number) + '/')

    else:
        reply_form = NewReplyForm()
        modify_form = ModifyTopicForm()
        topic.clicks = topic.clicks + 1
        topic.save()
        return render_to_response('corporation/topic_corporation.html', {
            'corporation': corporation,
            'current_user': request.user,
            'reply_form': reply_form,
            'topic': topic,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Esempio n. 6
0
def showtopic(request, gurl_number, turl_number):
    group = Group.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    topic.clicks = topic.clicks + 1
    topic.save()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sgcard = S_G_Card.objects(user=request.user, group=group).get()
                reply.creator = sgcard
                reply.creat_time = datetime.datetime.now()
                reply.target = topic
                reply.is_active = True
                reply.save()
                topic.update_author = request.user
                topic.update_time = datetime.datetime.now()
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/group/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
            
        if "modify" in request.POST:
            modify_form = ModifyTopicForm(request.POST)
            if modify_form.is_valid():
                content = modify_form.cleaned_data['content']
                topic.content = content
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/group/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
        
    else:
        reply_form = NewReplyForm()
        modify_form = ModifyTopicForm()
        topic.clicks = topic.clicks + 1
        topic.save()
        return render_to_response('group/group_topic.html', {'group':group, 'current_user':request.user, 'reply_form':reply_form, 'topic':topic, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Esempio n. 7
0
def showtopic(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    topic.clicks += 1
    topic.save()
    if request.method == 'POST':
        form = NewReplyForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            reply = Reply(content=content)
            sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
            reply.creator = sccard
            reply.creat_time = datetime.datetime.now()
            reply.target = topic
            reply.is_active = True
            reply.save()
            topic.update_author = request.user
            topic.update_time = datetime.datetime.now()
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
        
    else:
        form = NewReplyForm()
        return render_to_response('corporation/topic_corporation.html', {'corporation':corporation, 'current_user':request.user, 'form':form, 'topic':topic, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))