コード例 #1
0
ファイル: coursesubops.py プロジェクト: unicod3/ab-kurs-kayit
	def createCourse(self,request,insts):
		try:
			start_date=request.POST['start_date_year']+'-'+request.POST['start_date_month']+'-'+request.POST['start_date_day']
			end_date=request.POST['end_date_year']+'-'+request.POST['end_date_month']+'-'+request.POST['end_date_day']
			course = Course(name= request.POST['name'],description=request.POST['description'],
							goal= request.POST['goal'],partipation_rules=request.POST['partipation_rules'],
							start_date= start_date,end_date=end_date,fulltext = request.FILES['fulltext'])
			for i in insts:
				course.trainers.add(i)
			course.save()
			return 1
		except:
			return -1
コード例 #2
0
ファイル: modelops.py プロジェクト: bluevoda/ab-kurs-kayit
def savecourses():
    with open("courses") as e:
        kurslar = e.readlines()
        for kurs in kurslar:
            print kurs
            try:
                print "olustu"
                cols=kurs.split('|')
                kursm = Course(no=cols[0],name=cols[1],description='',
                               approved=True,site=Site.objects.get(is_active=True),
                               url="http://ab.org.tr/ab16/kursdir/"+str(cols[0])+".html")
                kursm.save()
                for egit in cols[2].split(','):
                    print egit
                    user=User.objects.get(username=egit.rstrip())
                    kursm.trainer.add(UserProfile.objects.get(user=user))
                kursm.save()
            except:
                print "olusmadi"
コード例 #3
0
 def createCourse(self, request, insts):
     try:
         start_date = request.POST['start_date_year'] + '-' + request.POST[
             'start_date_month'] + '-' + request.POST['start_date_day']
         end_date = request.POST['end_date_year'] + '-' + request.POST[
             'end_date_month'] + '-' + request.POST['end_date_day']
         course = Course(
             name=request.POST['name'],
             description=request.POST['description'],
             goal=request.POST['goal'],
             partipation_rules=request.POST['partipation_rules'],
             start_date=start_date,
             end_date=end_date,
             fulltext=request.FILES['fulltext'])
         for i in insts:
             course.trainers.add(i)
         course.save()
         return 1
     except:
         return -1
コード例 #4
0
ファイル: modelops.py プロジェクト: mdisec/ab-kurs-kayit
def savecourses():
    with open("courses") as e:
        kurslar = e.readlines()
        for kurs in kurslar:
            print kurs
            try:
                print "olustu"
                cols = kurs.split('|')
                kursm = Course(no=cols[0],
                               name=cols[1],
                               description='',
                               approved=True,
                               site=Site.objects.get(is_active=True),
                               url="http://ab.org.tr/ab16/kursdir/" +
                               str(cols[0]) + ".html")
                kursm.save()
                for egit in cols[2].split(','):
                    print egit
                    user = User.objects.get(username=egit.rstrip())
                    kursm.trainer.add(UserProfile.objects.get(user=user))
                kursm.save()
            except:
                print "olusmadi"