Esempio n. 1
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            #Lấy url của image
            try:
                token_image = request.FILES['image']
            except:
                token_image = None
            ima = ''
            if token_image != None:
                ima = tokenFile(token_image)

            if request.method == 'POST':
                footer = Footer(footername=request.POST['footername'],
                                createdate=datetime.now(),
                                editdate=datetime.now(),
                                content=request.POST['content'],
                                link=request.POST['link'],
                                image=ima,
                                isenable=request.POST['isenable'],
                                note=request.POST['note'])
                footer.save()
                return redirect('/adminfooter/')
            userdetail = UserDetail.objects.get(accountid=account)
            context = {
                'userdetail': userdetail,
                'account': account,
            }
            return render(request, 'adminfooter/footer_create.html', context)
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 2
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            footer = Footer.objects.get(footerid=id)
            #Lấy url của image
            try:
                token_image = request.FILES['image']
            except:
                token_image = None
            ima = ''
            if token_image != None:
                ima = tokenFile(token_image)
            else:
                ima = footer.image

            footer.footername = request.POST['footername']
            footer.createdate = footer.createdate
            footer.editdate = datetime.now()
            footer.content = request.POST['content']
            footer.link = request.POST['link']
            footer.image = ima
            footer.isenable = request.POST['isenable']
            footer.note = request.POST['note']
            footer.save()
            return redirect('/adminfooter/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 3
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            sliderunbar = SlideRunBar.objects.get(sliderunbarid=id)
            #Lấy url của image
            try:
                token_image = request.FILES['image']
            except:
                token_image = None
            ima = ''
            if token_image != None:
                ima = tokenFile(token_image)
            else:
                ima = sliderunbar.image

            sliderunbar.sliderunbarrname = request.POST['sliderunbarname']
            sliderunbar.createdate = sliderunbar.createdate
            sliderunbar.editdate = datetime.now()
            sliderunbar.content = request.POST['content']
            sliderunbar.link = request.POST['link']
            sliderunbar.image = ima
            sliderunbar.isenable = request.POST['isenable']
            sliderunbar.note = request.POST['note']
            sliderunbar.save()
            return redirect('/adminsliderunbar/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 4
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username = request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            home = Home.objects.get(homeid=id)
                #Lấy url của image
            try:
                token_image = request.FILES['image']
            except:
                token_image = None
            ima = ''
            if token_image != None:
                ima = tokenFile(token_image)
            else:
                ima = home.image

            home.homename=request.POST['homename']
            home.createdate=home.createdate
            home.editdate=datetime.now()
            home.content=request.POST['content']
            home.link=request.POST['link']
            home.image=ima
            home.isenable=request.POST['isenable']
            home.note=request.POST['note']
            home.save()
            return redirect('/adminhome/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 5
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            if request.method == 'POST':
                #Lấy url của image
                try:
                    token_image = request.FILES['image']
                except:
                    token_image = None
                ima = ''
                if token_image != None:
                    ima = tokenFile(token_image)

                sliderunbar = SlideRunBar(
                    sliderunbarname=request.POST['sliderunbarname'],
                    createdate=datetime.now(),
                    editdate=datetime.now(),
                    content=request.POST['content'],
                    link=request.POST['link'],
                    image=ima,
                    isenable=request.POST['isenable'],
                    note=request.POST['note'])
                sliderunbar.save()
                return redirect('/adminsliderunbar/')
            return render(request, 'adminsliderunbar/sliderunbar_create.html')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 6
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            introduction = Introduction.objects.get(introductionid=id)
            if request.method == 'POST':
                # Lấy url của image
                try:
                    token_image = request.FILES['image']
                except:
                    token_image = None
                ima = ''
                if token_image != None:
                    ima = tokenFile(token_image)
                else:
                    ima = introduction.image

            introduction.introductionname = request.POST['introductionname']
            introduction.createdate = introduction.createdate
            introduction.editdate = datetime.now()
            introduction.content = request.POST['content']
            introduction.link = request.POST['link']
            introduction.image = ima
            introduction.isenable = request.POST['isenable']
            introduction.note = request.POST['note']
            introduction.save()
            return redirect('/adminintroduction/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 7
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username = request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            subjectpart = SubjectPart.objects.get(subjectpartid = id)
            try:
                token_avatar = request.FILES['avatar']
            except:
                token_avatar = None
            ava = ''
            if token_avatar != None:
                ava = tokenFile(token_avatar)
            else:
                ava = subjectpart.avatar

            subjectpart = SubjectPart.objects.filter(subjectpartid = id).update(accountid = Account.objects.get(accountid = getNum(request.POST['accountid'])))
            subjectpart = SubjectPart.objects.filter(subjectpartid = id).update(subjectid = Subject.objects.get(subjectid = getNum(request.POST['subjectid'])))
            subjectpart = SubjectPart.objects.get(subjectpartid=id)
            subjectpart.subjectpartname=request.POST['subjectpartname']
            subjectpart.createdate=subjectpart.createdate
            subjectpart.editdate=datetime.now()
            subjectpart.avatar=ava
            subjectpart.description=request.POST['description']
            subjectpart.content=request.POST['content']
            subjectpart.order=request.POST['order']
            subjectpart.isenable=request.POST['isenable']
            subjectpart.note=request.POST['note']
            subjectpart.save()
            return redirect('/adminsubjectpart/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 8
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username = request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            news = News.objects.filter(newsid = id).update(accountid = Account.objects.get(accountid = getNum(request.POST['accountid'])))
            news = News.objects.filter(newsid = id).update(enviromentcateid = EnviromentCate.objects.get(enviromentcateid = getNum(request.POST['enviromentcateid'])))
            news = News.objects.get(newsid=id)

            # Lấy url của avatar
            try:
                token_avatar = request.FILES['avatar']
            except:
                token_avatar = None
            ava = ''
            if token_avatar != None:
                ava = tokenFile(token_avatar)
            else:
                ava = news.avatar

            news.newsname=request.POST['newsname']
            news.createdate=news.createdate
            news.editdate=datetime.now()
            news.isenable=ava
            news.description=request.POST['description']
            news.content=request.POST['content']
            news.isenable=request.POST['isenable']
            news.note=request.POST['note']
            news.save()
            return redirect('/adminnews/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 9
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            if request.method == 'POST':
                try:
                    token_avatar = request.FILES['avatar']
                except:
                    token_avatar = None
                ava = ''
                if token_avatar != None:
                    ava = tokenFile(token_avatar)
                subjectpart = SubjectPart(
                    accountid=Account.objects.get(
                        accountid=request.POST['accountid']),
                    subjectid=Subject.objects.get(
                        subjectid=request.POST['subjectid']),
                    subjectpartname=request.POST['subjectpartname'],
                    createdate=datetime.now(),
                    editdate=datetime.now(),
                    description=request.POST['description'],
                    content=request.POST['content'],
                    avatar=ava,
                    order=request.POST['order'],
                    isenable=request.POST['isenable'],
                    note=request.POST['note'])
                subjectpart.save()
                return redirect('/adminsubjectpart/')
            else:
                accounts = Account.objects.all()
                subjects = Subject.objects.all()

                for account in accounts:
                    account.createdate = account.createdate
                    account.editdate = account.editdate
                for subject in subjects:
                    subject.createdate = subject.createdate
                    subject.editdate = subject.editdate
                userdetail = UserDetail.objects.get(accountid=account)
                context = {
                    'userdetail': userdetail,
                    'account': account,
                    'accounts': accounts,
                    'subjects': subjects
                }
            return render(request, 'adminsubjectpart/subjectpart_create.html',
                          context)
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 10
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            competition = Competition.objects.filter(competitionid=id).update(
                accountid=Account.objects.get(
                    accountid=getNum(request.POST['accountid'])))
            competition = Competition.objects.filter(competitionid=id).update(
                enviromentcateid=EnviromentCate.objects.get(
                    enviromentcateid=getNum(request.POST['enviromentcateid'])))
            competition = Competition.objects.get(competitionid=id)

            #Lấy url của avatar
            try:
                token_avatar = request.FILES['image']
            except:
                token_avatar = None
            ava = ''
            if token_avatar != None:
                ava = tokenFile(token_avatar)
            else:
                ava = competition.avatar

            if request.POST['opendate'] == '':
                opendate = competition.opendate
            else:
                opendate = request.POST['opendate']
            if request.POST['enddate'] == '':
                enddate = competition.enddate
            else:
                enddate = request.POST['enddate']

            competition.competitionname = request.POST['competitionname']
            competition.createdate = competition.createdate
            competition.editdate = datetime.now()
            competition.opendate = opendate
            competition.enddate = enddate
            competition.description = request.POST['description']
            competition.content = request.POST['content']
            competition.avatar = ava
            competition.viewcount = request.POST['viewcount']
            competition.likecount = request.POST['likecount']
            competition.isenable = request.POST['isenable']
            competition.note = request.POST['note']
            competition.save()
            return redirect('/admincompetition/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 11
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            projectshare = ProjectShare.objects.filter(
                projectsharetopicid=id).update(accountid=Account.objects.get(
                    accountid=getNum(request.POST['accountid'])))

            if request.POST.get('enviromentcateid') != '0':
                projectshare = ProjectShare.objects.filter(
                    projectsharetopicid=id
                ).update(enviromentcateid=EnviromentCate.objects.get(
                    enviromentcateid=getNum(request.POST['enviromentcateid'])))
            projectshare = ProjectShare.objects.get(projectsharetopicid=id)

            # Lấy url của avatar
            try:
                token_avatar = request.FILES['avatar']
            except:
                token_avatar = None
            ava = ''
            if token_avatar != None:
                ava = tokenFile(token_avatar)
            else:
                ava = projectshare.avatar

            projectshare.projectsharetopicname = request.POST[
                'projectsharename']
            projectshare.createdate = projectshare.createdate
            projectshare.editdate = datetime.now()
            projectshare.description = request.POST['description']
            projectshare.content = request.POST['content']
            projectshare.link = request.POST['link']
            projectshare.viewcount = request.POST['viewcount']
            projectshare.likecount = request.POST['likecount']
            projectshare.isenable = request.POST['isenable']
            projectshare.avatar = ava
            projectshare.note = request.POST['note']
            projectshare.save()
            return redirect('/adminprojectshare/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 12
0
def update(request, id):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            competitionsubmittion = CompetitionSubmittion.objects.filter(
                competitionsubmittionid=id).update(
                    accountid=Account.objects.get(
                        accountid=getNum(request.POST['accountid'])))
            # competitionsubmittion = CompetitionSubmittion.objects.filter(competitionsubmittionid = id).update(enviromentcateid = EnviromentCate.objects.get(enviromentcateid = getNum(request.POST['enviromentcateid'])))
            competitionsubmittion = CompetitionSubmittion.objects.filter(
                competitionsubmittionid=id).update(
                    competitionid=Competition.objects.get(
                        competitionid=getNum(request.POST['competitionid'])))
            competitionsubmittion = CompetitionSubmittion.objects.get(
                competitionsubmittionid=id)

            try:
                token_link = request.FILES['link']
            except:
                token_link = None
            lin = ''
            if token_link != None:
                lin = tokenFile(token_link)
            else:
                lin = competitionsubmittion.link

            competitionsubmittion.createdate = competitionsubmittion.createdate
            competitionsubmittion.editdate = datetime.now()
            competitionsubmittion.link = lin
            competitionsubmittion.description = request.POST['description']
            competitionsubmittion.content = request.POST['content']
            competitionsubmittion.isenable = request.POST['isenable']
            competitionsubmittion.note = request.POST['note']
            competitionsubmittion.save()
            return redirect('/admincompetitionsubmittion/')
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 13
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            if request.method == 'POST':
                try:
                    token_link = request.FILES['link']
                except:
                    token_link = None
                lin = ''
                if token_link != None:
                    lin = tokenFile(token_link)
                competitionsubmittion = CompetitionSubmittion(
                    accountid=Account.objects.get(
                        accountid=request.POST['accountid']),
                    # enviromentcateid = Account.objects.get(accountid = request.POST['enviromentcateid']),
                    competitionid=Competition.objects.get(
                        competitionid=request.POST['competitionid']),
                    createdate=datetime.now(),
                    editdate=datetime.now(),
                    link=lin,
                    description=request.POST['description'],
                    content=request.POST['content'],
                    isenable=request.POST['isenable'],
                    note=request.POST['note'])
                competitionsubmittion.save()
                return redirect('/admincompetitionsubmittion/')
            else:
                competitions = Competition.objects.all()
                for competition in competitions:
                    competition.createdate = competition.createdate
                    competition.editdate = competition.editdate
                    competition.opendate = competition.opendate.strftime(
                        "%Y-%m-%d %H:%M:%S")
                    competition.enddate = competition.enddate.strftime(
                        "%Y-%m-%d %H:%M:%S")

                accounts = Account.objects.all()
                # subjects = Subject.objects.all()
                enviromentcates = EnviromentCate.objects.all()
                for account in accounts:
                    account.createdate = account.createdate
                    account.editdate = account.editdate

                # for subject in subjects:
                #     subject.createdate = subject.createdate
                #     subject.editdate = subject.editdate

                for enviromentcate in enviromentcates:
                    enviromentcate.createdate = enviromentcate.createdate
                    enviromentcate.editdate = enviromentcate.editdate

                context = {
                    'accounts': accounts,
                    # 'subjects': subjects,
                    'competitions': competitions,
                    'enviromentcates': enviromentcates,
                }

            return render(
                request,
                'admincompetitionsubmittion/competitionsubmittion_create.html',
                context)
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 14
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username=request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            if request.method == 'POST':
                # Lấy url của avatar
                try:
                    token_avatar = request.FILES['avatar']
                except:
                    token_avatar = None
                ava = ''
                if token_avatar != None:
                    ava = tokenFile(token_avatar)

                projectshare = ProjectShare(
                    accountid=Account.objects.get(
                        accountid=request.POST['accountid']),
                    enviromentcateid=EnviromentCate.objects.get(
                        enviromentcateid=request.POST['enviromentcateid']),
                    projectsharetopicname=request.POST['projectsharename'],
                    createdate=datetime.now(),
                    editdate=datetime.now(),
                    description=request.POST['description'],
                    content=request.POST['content'],
                    avatar=ava,
                    link=request.POST['link'],
                    viewcount=request.POST['viewcount'],
                    likecount=request.POST['likecount'],
                    isenable=request.POST['isenable'],
                    note=request.POST['note'])
                projectshare.save()
                return redirect('/adminprojectshare/')
            else:
                # subjectparts = SubjectPart.objects.all()
                # for subjectpart in subjectparts:
                #     subjectpart.createdate = subjectpart.createdate
                #     subjectpart.editdate = subjectpart.editdate

                enviromentcates = EnviromentCate.objects.all()
                for enviromentcate in enviromentcates:
                    enviromentcate.createdate = enviromentcate.createdate
                    enviromentcate.editdate = enviromentcate.editdate

                accounts = Account.objects.all()
                subjects = Subject.objects.all()

                for account in accounts:
                    account.createdate = account.createdate
                    account.editdate = account.editdate

                for subject in subjects:
                    subject.createdate = subject.createdate
                    subject.editdate = subject.editdate

                userdetail = UserDetail.objects.get(accountid=account)
                context = {
                    'userdetail': userdetail,
                    'account': account,
                    'accounts': accounts,
                    'subjects': subjects,
                    # 'subjectparts': subjectparts
                    'enviromentcates': enviromentcates,
                }

            return render(request,
                          'adminprojectshare/projectshare_create.html',
                          context)
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')
Esempio n. 15
0
def create(request):
    if request.session.has_key('username'):
        account = Account.objects.get(username = request.session['username'])
        if account.accounttypeid.accounttypeid == 1:
            if request.method == 'POST':
                # Lấy url của avatar
                try:
                    token_avatar = request.FILES['avatar']
                except:
                    token_avatar = None
                ava = ''
                if token_avatar != None:
                    ava = tokenFile(token_avatar)
                

                news = News( 
                                        accountid = Account.objects.get(accountid = request.POST['accountid']),
                                        enviromentcateid = EnviromentCate.objects.get(enviromentcateid = request.POST['enviromentcateid']),
                                        newsname=request.POST['newsname'], 
                                        createdate= datetime.now(), 
                                        editdate= datetime.now(),
                                        description=request.POST['description'],
                                        content=request.POST['content'],
                                        avatar=ava,
                                        isenable=request.POST['isenable'],  
                                        note=request.POST['note'])
                news.save()
                return redirect('/adminnews/')
            else:
                # subjectparts = SubjectPart.objects.all()
                # for subjectpart in subjectparts:
                #     subjectpart.createdate = subjectpart.createdate
                #     subjectpart.editdate = subjectpart.editdate

                enviromentcates = EnviromentCate.objects.all()
                for enviromentcate in enviromentcates:
                    enviromentcate.createdate = enviromentcate.createdate
                    enviromentcate.editdate = enviromentcate.editdate
                
                accounts = Account.objects.all()
                subjects = Subject.objects.all()
                
                for account in accounts:
                    account.createdate = account.createdate
                    account.editdate = account.editdate

                for subject in subjects:
                    subject.createdate = subject.createdate
                    subject.editdate = subject.editdate

                context = {
                    'accounts': accounts,
                    'subjects': subjects,
                    # 'subjectparts': subjectparts,
                    'enviromentcates': enviromentcates,
                }   
            
            return render(request, 'adminnews/news_create.html', context)
        else:
            return redirect('homepage:index')
    else:
        return redirect('homepage:index')