def create_team(request): if request.method != 'POST': return render(request, 'team/create_team.html', {'form': TeamCreationForm()}) # Stop if a person tries to create more than the allowed ammount of teams. if Team.objects.filter(leader=request.user).count() >= settings.MAX_TEAMS: messages.error( request, _(u'You can\'t be the leader of more than {max} teams.').format( max=settings.MAX_TEAMS)) return redirect('teams') form = TeamCreationForm(request.POST) if form.is_valid(): cleaned = form.cleaned_data team = Team( leader=request.user, title=cleaned['title'], tag=cleaned['tag'], ) team.save() messages.success(request, _(u'Team {team} has been created.').format(team=team)) return redirect(team) else: # Return with errors form = TeamCreationForm(request.POST, auto_id=True, error_class=InlineSpanErrorList) return render(request, 'team/create_team.html', {'form': form})
def create_team(request): if request.method == 'POST': # Stop if a person tries to create more than the allowed ammount of teams. if Team.objects.filter(leader=request.user).count() >= settings.MAX_TEAMS: messages.error(request, _(u'You cannot be leader of more than ') + settings.MAX_TEAMS + _(u' teams.')) return redirect('teams') form = TeamCreationForm(request.POST) if form.is_valid(): cleaned = form.cleaned_data team = Team( leader=request.user, title=cleaned['title'], tag=cleaned['tag'], ) team.save() messages.success(request, unicode(team) + _(u' has been created.')) return redirect(team) else: form = TeamCreationForm(request.POST, auto_id=True, error_class=InlineSpanErrorList) else: form = TeamCreationForm() breadcrumbs = ( (settings.SITE_NAME, '/'), (_(u'Teams'), reverse('teams')), (_(u'Create team'), ''), ) return render(request, 'team/create_team.html', {'breadcrumbs': breadcrumbs, 'form': form})
def saveTeam(user,postData): teams = Team.objects.filter(manager=user,status=1) if len(teams) > 0: return False else: team = Team() team.id_code = fileLogics.getIdCode("TEAM") team.manager = user user.status = 'manager' team.name = postData['name'] team.profile = team.id_code # logo = postData['logo'] team.school = postData['school'] team.desc = postData['desc'] teamProfile = TeamProfile() teamProfile = defaultProfile(teamProfile,team.id_code) teamProfile.save() team.save() try: user.player.team = team user.player.save() user.status = 'manager' except: pass user.save() fileLogics.setIdCode("TEAM",int(team.id_code)+1) return True;
def create(account, name, country, logo, application): team = None with transaction.commit_on_success(): team = Team() team.name = name team.link = uslugify(name) team.country = country team.logo = logo team.application = application team.created_by = account team.updated_by = account team.save() team.members.add(account) signals.team_created.send(sender=create, team=team, creator=account) return team
def saveTeam(user,postData): teams = Team.objects.filter(user=user,status=1) if teams.length > 0: team = teams[0] else: team = Team() team.id_code = fileLogics.getTeamIdCode() team.manager = user user.status = 'manager' team.name = postData['name'] profile = postData['name'] logo = postData['logo'] school = postData['school'] desc = postData['desc'] os.mkdir(os.path.join(setting.TEAM_PROFILE_DIR,team.name)) with open(settings.TEAM_PROFILE_DIR+"/"+team.name+"/profile","wb+") as fp: fp.write("") team.save() user.save() fileLogics.setTeamIdCode(team.id_code+1) return True;