示例#1
0
文件: views.py 项目: lqchn/lqchn
def createNewActivity(request):
	title = request.POST['title']
	host = request.POST['host']
	undertake = request.POST['undertake']
	time = request.POST['time']
	area = request.POST['area']
	place = request.POST['place']
	tel = request.POST['tel']
	email = request.POST['email']
	brief = request.POST['brief']
	detail = request.POST['detail']
	number = int(request.POST['number'])
	c_id = request.POST['c_id']

	club = Club.objects.get(id=c_id)

	today = str(date.today().year)+'-'+str(date.today().month)+'-'+str(date.today().day)

	#basic information
	information = activityInfo()
	information.title = title
	information.host = host
	information.undertake = undertake
	information.time = time
	information.area = area
	information.place = place
	information.tel = tel
	information.email = email
	information.number = number
	information.save()

	#host club
	host = hostClub()
	host.HC_club = club
	host.save()

	#record
	record = recordInfo()
	record.save()

	#create new activity
	new_activity = Activity()
	new_activity.information = information
	new_activity.club = host
	new_activity.school = club.school
	new_activity.record = record
	new_activity.brief_intro = brief
	new_activity.detail_intro = detail

	form = uploadFileForm(request.POST, request.FILES)
	if form.is_valid():
		new_activity.image = request.FILES['image']
		new_activity.safe_file = request.FILES['safe_file']

	new_activity.save()

	createGlobalNews(club.id,new_activity.id,'3')

	return HttpResponse('1')