Esempio n. 1
0
def activityS(request):
    if check_permission(request):
        activity = Board.objects.all().order_by('-date')
        p = Paginator(activity, 10)
        page = request.GET.get('page')
        activity = p.get_page(page)
        return render(request,'activity.html',{'activity' : activity})
Esempio n. 2
0
def addActivity_summit(request):
    if check_permission(request):
        # titleboard = request.POST["titleboard"]
        # # date = request.POST['date']
        # detail = request.POST["detail"]
        # # image = request.POST["image"]
        # board = Board(titleboard=titleboard,detail=detail)
        # board.save()
        return render(request,'staff/addActivity.html')    
Esempio n. 3
0
def delete_news(request,pk):
    if check_permission(request):
        news = News.objects.filter(pk=pk)
        if news.exists():
                news = news[0]
        else:
                return HttpResponseNotFound()
        news.delete()
        return redirect('scinews:home')
Esempio n. 4
0
def delete_Exam(request,pk):
        if check_permission(request):
                cate = Exam.objects.filter(pk=pk)
                if cate.exists():
                        cate = cate[0]
                else:
                        return HttpResponseNotFound()
                cate.delete()
                return redirect('scinews:examsub',name=cate.category.name)
Esempio n. 5
0
def addNews(request):
    if check_permission(request):
        if request.method == 'POST':
            form = AddNewsForm(request.POST,request.FILES)
            if form.is_valid():
                form.save()
                return redirect('scinews:home')
        else:
            form = AddNewsForm()

        return render(request,'staff/addNews.html',{'form' : form,'title': 'เพิ่มข่าวสาร'})
Esempio n. 6
0
def delete_CategoryExam(request,name):
        if check_permission(request):
                cate = CategoryExam.objects.filter(name=name)
                if cate.exists():
                        cate = cate[0]
                        allcate = Exam.objects.filter(category=cate)
                else:
                        return HttpResponseNotFound()
                allcate.delete()
                cate.delete()
                return redirect('scinews:exam')
Esempio n. 7
0
def examS(request):
    if check_permission(request):
        context = dict()
        cate = dict()
        exams = Exam.objects.all()
        context['all'] = exams

        catExams = CategoryExam.objects.all()
        for cat in catExams:
            cate[str(cat)] = Exam.objects.filter(category=cat)[:5]
        context['category'] = cate
        return render(request,'exam.html',context)
Esempio n. 8
0
def addCategory(request):
    if check_permission(request):
        context = dict()
        if request.method == 'POST':
            form = AddCategoryExamForm(request.POST)
            if form.is_valid():
                form.save()
                return redirect('scinews:exam')
        else:
            context['form'] = AddCategoryExamForm()
            context['title'] = 'เพิ่มหมวดหมู่'

        return render(request,'staff/addNews.html',context)
Esempio n. 9
0
def addActivity(request):
    if check_permission(request):
        # pylint: disable=no-member
        # activity = Board.objects.all()
        if request.method == 'POST':
            form = AddBoard(request.POST,request.FILES)
            if form.is_valid():
                form.save()
                #save to db
                return redirect('scinews:activity')
        else:
            form = AddBoard()
        return render(request,'staff/addActivity.html',{'form':form})
Esempio n. 10
0
def update_activity(request,**kwargs):
    if check_permission(request):
        # pylint: disable=no-member
        pk = kwargs['pk']
        u = Board.objects.get(pk=pk)
        if not u:
            return redirect('scinews:activity')
        if request.method == 'POST':
            form = AddBoard(request.POST,request.FILES,instance=u)
            if form.is_valid():
                form.save()
                return redirect('scinews:activity')
        else:
            form = AddBoard(instance=u)
        return render(request,'staff/update_activity.html',{'form':form})
Esempio n. 11
0
def updateNews2(request,**kwargs):
    if check_permission(request):
        pk = kwargs['pk']
        # pylint: disable=no-member
        u = News.objects.get(pk=pk)
        if not u:
            return redirect('scinews:home')
        if request.method == 'POST':
            form = AddNewsForm(request.POST,request.FILES,instance=u)
            if form.is_valid():
                form.save()
                return redirect('scinews:home')
        else:
            form = AddNewsForm(instance=u)
        return render(request,'staff/update_news.html',{'form' : form})
Esempio n. 12
0
def addExam(request):
    if check_permission(request):
        if request.method == 'POST':
            form = AddExamForm(request.POST,request.FILES)
            if form.is_valid():
                form.save()
                #save to db
                return redirect('scinews:exam')
        else:
            form = AddExamForm()
        return render(request,'staff/addExam.html',{'form':form})

# @login_required
# def addExam_summit(request):
#     if check_permission(request):
        # titleexam = request.POST["titleexam"]
        # link = request.POST["link"]
        # date = request.POST["date"]
        # # category = request.POST["category"]
        # exam = Exam(titleexam=titleexam,link=link,date=date)
        # exam.save()
        # return redirect('scinews:exam')

# def delete_english(request,id):
#     #     #delete
#     deleteeng = Exam.objects.get(pk=id).delete()
    
#     return redirect('englishS')

# def delete_math(request,id):
#     deletemath = Exam.objects.get(pk=id).delete()
#     return redirect('mathS')

# def delete_others(request,id):
#     deleteothers = Exam.objects.get(pk=id).delete()
#     return redirect('othersS')

# ------------------Staff-------------------
Esempio n. 13
0
def delete_board(request,**kwargs):
    if check_permission(request):
        pk = kwargs['pk']
        # pylint: disable=no-member
        Board.objects.get(pk=pk).delete()
        return redirect('scinews:activity')
Esempio n. 14
0
def updateNews(request,**kwargs):
    if check_permission(request):
        pk = kwargs['pk']
        news = News.objects.get(pk=pk)
        return render(request,'staff/update_news.html',{'news':news})