示例#1
0
def view_activity_comments(request, activity_id):
    activity = get_object_or_404(Activity, pk=activity_id)
    
    if request.method == 'POST':
        if 'submit_comment_button' in request.POST:
            form = PostCommentForm(request.POST)
            
            if form.is_valid():
                comment_functions.post_comment_for('activity', activity_id, form.cleaned_data['comment_message'], request.user.get_profile())
                messages.success(request, 'เพิ่มความคิดเห็นเรียบร้อย')
                return redirect('view_activity_comments', activity_id)
            
        elif 'submit_reply_button' in request.POST:
            comment_id = request.POST['comment_id']
            message = request.POST['comment_message']
            
            comment = get_object_or_404(Comment, pk=comment_id)
            if message:
                comment_functions.post_reply_comment_for(comment, 'activity', activity_id, message, request.user.get_profile())
                messages.success(request, 'ตอบกลับความคิดเห็นเรียบร้อย')
                return redirect('view_activity_comments', activity_id)
        
    else:
        form = PostCommentForm()
    
    comments = comment_functions.get_comments_for('activity', activity_id, request.user.get_profile(), mark_as_read=True)
    return render_page_response(request, 'comments', 'page_program/activity_comments.html', {'activity':activity, 'comments':comments, 'form':form})
示例#2
0
def view_activity_comments(request, activity_id):
    activity = get_object_or_404(Activity, pk=activity_id)

    if request.method == 'POST':
        if 'submit_comment_button' in request.POST:
            form = PostCommentForm(request.POST)

            if form.is_valid():
                comment_functions.post_comment_for(
                    'activity', activity_id,
                    form.cleaned_data['comment_message'],
                    request.user.get_profile())
                messages.success(request, 'เพิ่มความคิดเห็นเรียบร้อย')
                return redirect('view_activity_comments', activity_id)

        elif 'submit_reply_button' in request.POST:
            comment_id = request.POST['comment_id']
            message = request.POST['comment_message']

            comment = get_object_or_404(Comment, pk=comment_id)
            if message:
                comment_functions.post_reply_comment_for(
                    comment, 'activity', activity_id, message,
                    request.user.get_profile())
                messages.success(request, 'ตอบกลับความคิดเห็นเรียบร้อย')
                return redirect('view_activity_comments', activity_id)

    else:
        form = PostCommentForm()

    comments = comment_functions.get_comments_for('activity',
                                                  activity_id,
                                                  request.user.get_profile(),
                                                  mark_as_read=True)
    return render_page_response(request, 'comments',
                                'page_program/activity_comments.html', {
                                    'activity': activity,
                                    'comments': comments,
                                    'form': form
                                })
示例#3
0
def view_report_comments(request, program_id, report_id, schedule_dateid):
    program = get_object_or_404(Program, pk=program_id)
    report = get_object_or_404(Report, pk=report_id)
    schedule_date = utilities.convert_dateid_to_date(schedule_dateid)
    
    try:
        submission = ReportSubmission.objects.get(program=program, report=report, schedule_date=schedule_date)
    except:
        submission = ReportSubmission(program=program, report=report, schedule_date=schedule_date)
    
    if request.method == 'POST':
        if 'submit_comment_button' in request.POST:
            form = PostCommentForm(request.POST)
            
            if form.is_valid():
                if not submission.id: submission.save()
                comment_functions.post_comment_for('report', submission.id, form.cleaned_data['comment_message'], request.user.get_profile())
                messages.success(request, 'เพิ่มความคิดเห็นเรียบร้อย')
                return redirect('view_report_comments', program_id=program.id, report_id=report.id, schedule_dateid=schedule_dateid)
            
        elif 'submit_reply_button' in request.POST:
            comment_id = request.POST['comment_id']
            message = request.POST['comment_message']
            
            comment = get_object_or_404(Comment, pk=comment_id)
            if message:
                comment_functions.post_reply_comment_for(comment, 'report', submission.id, message, request.user.get_profile())
                messages.success(request, 'ตอบกลับความคิดเห็นเรียบร้อย')
                return redirect('view_report_comments', program_id=program.id, report_id=report.id, schedule_dateid=schedule_dateid)
        
    else:
        form = PostCommentForm()
    
    if submission.id:
        comments = comment_functions.get_comments_for('report', submission.id, request.user.get_profile(), mark_as_read=True)
    else:
        comments = []
    
    return render_page_response(request, 'comments', 'page_report/report_comments.html', {'submission':submission, 'comments':comments, 'form':form})
示例#4
0
def view_report_comments(request, program_id, report_id, schedule_dateid):
    program = get_object_or_404(Program, pk=program_id)
    report = get_object_or_404(Report, pk=report_id)
    schedule_date = utilities.convert_dateid_to_date(schedule_dateid)

    try:
        submission = ReportSubmission.objects.get(program=program,
                                                  report=report,
                                                  schedule_date=schedule_date)
    except:
        submission = ReportSubmission(program=program,
                                      report=report,
                                      schedule_date=schedule_date)

    if request.method == 'POST':
        if 'submit_comment_button' in request.POST:
            form = PostCommentForm(request.POST)

            if form.is_valid():
                if not submission.id: submission.save()
                comment_functions.post_comment_for(
                    'report', submission.id,
                    form.cleaned_data['comment_message'],
                    request.user.get_profile())
                messages.success(request, 'เพิ่มความคิดเห็นเรียบร้อย')
                return redirect('view_report_comments',
                                program_id=program.id,
                                report_id=report.id,
                                schedule_dateid=schedule_dateid)

        elif 'submit_reply_button' in request.POST:
            comment_id = request.POST['comment_id']
            message = request.POST['comment_message']

            comment = get_object_or_404(Comment, pk=comment_id)
            if message:
                comment_functions.post_reply_comment_for(
                    comment, 'report', submission.id, message,
                    request.user.get_profile())
                messages.success(request, 'ตอบกลับความคิดเห็นเรียบร้อย')
                return redirect('view_report_comments',
                                program_id=program.id,
                                report_id=report.id,
                                schedule_dateid=schedule_dateid)

    else:
        form = PostCommentForm()

    if submission.id:
        comments = comment_functions.get_comments_for(
            'report',
            submission.id,
            request.user.get_profile(),
            mark_as_read=True)
    else:
        comments = []

    return render_page_response(request, 'comments',
                                'page_report/report_comments.html', {
                                    'submission': submission,
                                    'comments': comments,
                                    'form': form
                                })