def createNewClub(request): u_id = request.POST['u_id'] name = request.POST['club_name'] intro = request.POST['club_intro'] c_name = request.POST['c_name'] tel = request.POST['club_tel'] email = request.POST['club_email'] cb_type = request.POST['club_type'] numMembers = request.POST['numMembers'] u = User_C.objects.get(id=u_id) school = u.school today = str(date.today().year)+'-'+str(date.today().month)+'-'+str(date.today().day) #basic information information = clubInfo() information.name = name information.create_name = c_name information.introduction = intro information.cb_type = cb_type information.dateFound = today information.tel = tel information.email = email information.numMember = numMembers form = uploadLogoForm(request.POST,request.FILES) if form.is_valid(): information.logo = request.FILES['logo'] information.save() #founder information founder = founderInfo(FI_user=u) founder.save() #record record = recordInfo() record.save() #create Club new_club = Club() new_club.information = information new_club.founder = founder new_club.school = school new_club.record = record new_club.save() createGlobalNews(u_id,new_club.id,'1') return HttpResponse('1')
def make_club(ownerid,name,university,about="",members=[],admins=[],private=True,callback=None): if len(name) <= 0: return 500 admins = admins logger.debug("Name "+ name) logger.debug("Admins " + str(admins)) logger.debug("Members " + str(members)) if ownerid not in admins: admins.append(ownerid) if ownerid not in members: members.append(ownerid) club = Club(Admins=admins,Members=members,About=about,Name=name,University=university,Private=private) club.save() for userid in members: user = User.objects(id=userid).first() subc = SubClub(Id=club.id,Name=name) user.Clubs.append(subc) user.save() if callback != None: return callback(200) return 200
def build_clubs(): for c in clubs: club = Club(name=c) club.save()