コード例 #1
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def new(request, regionId):

    user = PermissionsManager.getPermissionsForUser(request.user)

    if not PermissionsManager.canCreateCompetition(user, regionId):
        return list(request)

    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

    if request.method == "POST":
        form = CompetitionTypeForm(request.POST)
        if form.is_valid():
            form.save()
            return list(request)
        else:
            return render(request, 'competitionsDetail.html', {
                'headerDto': headerDto,
                'competitionTypeForm': form
            })

    else:
        competitionTypeForm = CompetitionTypeForm(initial={'Region': user})

        return render(request, 'competitionsDetail.html', {
            'headerDto': headerDto,
            'competitionTypeForm': competitionTypeForm
        })
コード例 #2
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def list(request):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	licences = LicenceManager.getLicencesForUser(user)
	
	return render(request, 'licencesList.html', {'headerDto' : headerDto,
												'licences': licences})
コード例 #3
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def rosterListTeam(request):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	competitionsDto = RostersManager.getCompetitionRostersTeam(user)
	print(competitionsDto)
	return render(request, 'rosterList.html', {'headerDto' : headerDto,
											   'competitionsDto': competitionsDto})
コード例 #4
0
def listTeam(request):
	user = PermissionsManager.getPermissionsForUser(request.user)
	regionId = user.id
	region = RegionManager.getRegionById(regionId)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	
	playersDto = PlayerManager.getPlayersForTeam(region, user)
	
	return render(request, 'playersListTeam.html', {'headerDto' : headerDto,
												'playersDto': playersDto})
コード例 #5
0
def newPlayer(request, teamId):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	selectPlayerForm = SelectPlayerForm(request.POST or None)

	if request.method == "POST":
		if selePlayerForm.is_valid():
		
			player = PlayerManager.findPlayerByIdNumber(selectPlayerForm.cleaned_data['my_form_field_name'])
			return editPlayerLicence(None, player)

	
	return render(request, 'findPlayer.html', { 'selectPlayerForm': selectPlayerForm,'headerDto' : headerDto})
コード例 #6
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def manageCompetition(request, competitionId):
    user = PermissionsManager.getPermissionsForUser(request.user)
    competition = CompetitionManager.getCompetitionTypeById(competitionId)
    region = competition.Region
    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

    if PermissionsManager.canManageEditions(user, region.id):
        competition = CompetitionManager.getEditions(competitionId)
        return render(request, 'competitionManage.html', {
            'headerDto': headerDto,
            'competition': competition
        })

    return redirect('/')
コード例 #7
0
def editPlayerLicence(request,player):

	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

	playerForm = PlayerForm(request.POST or None, instance= player)

	if request.method == "POST":
		if playerForm.is_valid():
			playerForm.save()
			return selectLicences(None, player)
			

	return render(request, 'newPlayer.html', {'headerDto':headerDto,
											'playerForm':playerForm})
コード例 #8
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def list(request):
    user = PermissionsManager.getPermissionsForUser(request.user)
    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

    competitions = {}

    if user.National:
        competitions = CompetitionManager.getAllCompetitionTypes()
    else:
        competitions = CompetitionManager.getCompetitionsTypesRegion(user)

    return render(request, 'competitionList.html', {
        'headerDto': headerDto,
        'competitions': competitions
    })
コード例 #9
0
def listRegion(request,regionId):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	regions = {}
	region = RegionManager.getRegionById(regionId)

	result = RegionManager.getAllRegions()
	for regionElement in result:
		regions[regionElement.RegionName] = RegionDto(regionElement)
	if PermissionsManager.canListPlayersRegion(user,regionId):
		playersDto = PlayerManager.getPlayersForRegion(region)
		
		return render(request, 'playersList.html', {'headerDto': headerDto,
													'regions': regions,
													'playersDto': playersDto})
	else:
		return redirect('/')
コード例 #10
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def rosterListRegion(request, regionId):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	
	regions = {}
	result = RegionManager.getAllRegions()
	for regionElement in result:
		regions[regionElement.RegionName] = RegionDto(regionElement)

	if PermissionsManager.canListPlayersRegion(user,regionId):
		competitionsDto = RostersManager.getCompetitionRostersRegion(regionId)
		return render(request, 'rosterList.html', {'headerDto' : headerDto,
												'regions': regions,
												'competitionsDto': competitionsDto})
	
	else:
		return redirect('/')
コード例 #11
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def editCompetition(request, competitionId):
    user = PermissionsManager.getPermissionsForUser(request.user)
    competition = CompetitionManager.getCompetitionTypeById(competitionId)
    region = competition.Region

    if not PermissionsManager.canEditCompetition(user, region.id):
        return redirect('/')

    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
    form = CompetitionTypeForm(request.POST or None, instance=competition)
    if request.method == "POST":
        if form.is_valid():
            form.save()
            return list(request)

    return render(request, 'competitionsDetail.html', {
        'headerDto': headerDto,
        'competitionTypeForm': form
    })
コード例 #12
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def home(request):
    print(request.method)
    if request.method == "POST":
        username = request.POST['username']
        password = request.POST['password']
        user = PermissionsManager.getPermissions(username, password)

        if user:
            login(request, user.User)
            return landingPage(request, user)

        else:
            return render(request, 'login.html')
    else:
        if request.user.is_authenticated:
            user = PermissionsManager.getPermissionsForUser(request.user)
            return landingPage(request, user)
        else:
            return render(request, 'login.html')
コード例 #13
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def editLicence(request,licenceId):
	user = PermissionsManager.getPermissionsForUser(request.user)
	region =  LicenceManager.getLicenceById(licenceId).Type.Region

	if not PermissionsManager.canEditLicence(user,region):
		return list(request)
		
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

	licence = LicenceManager.getLicenceById(licenceId)
	licenceTypeForm = LicenceTypeForm(request.POST or None, instance = licence.Type)
	licenceDurationForm = LicenceDurationForm(request.POST or None, instance =  licence.Session)
	
	if request.method == "POST":		
		if licenceTypeForm.is_valid() and licenceDurationForm.is_valid():
			licenceTypeForm.save()			
			licenceDurationForm.save()			
			return list(request)

	
	return render(request, 'licencesDetail.html', {'headerDto': headerDto,
													'licenceTypeForm': licenceTypeForm,
													'licenceDurationForm': licenceDurationForm})
コード例 #14
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def new(request, regionId):

	user = PermissionsManager.getPermissionsForUser(request.user)

	if not PermissionsManager.canCreateLicence(user,regionId):	
		return list(request)

	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	licenceTypeForm = LicenceTypeForm(request.POST or None,initial={'Region': user})
	licenceDurationForm = LicenceDurationForm(request.POST or None)	

	if request.method == "POST":
		if licenceTypeForm.is_valid() and licenceDurationForm.is_valid():
			duration = licenceDurationForm.save()
			type = licenceTypeForm.save()			
			licence = Licence(Type=type,Session = duration)
			licence.save()

			return redirect(list)
		
	return render(request, 'licencesDetail.html', {'headerDto': headerDto,
													'licenceTypeForm': licenceTypeForm,
													'licenceDurationForm': licenceDurationForm})
コード例 #15
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def editConditions(request, competitionId):
    user = PermissionsManager.getPermissionsForUser(request.user)
    competition = CompetitionManager.getCompetitionById(competitionId)
    region = competition.Competition.Region
    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

    if PermissionsManager.canEditConditions(user, region.id):

        formCompetition = CompetitionEditionForm(request.POST or None,
                                                 instance=competition)
        formConditions = CompetitionConditionsForm(
            request.POST or None, instance=competition.Conditions)
        formLicences = CompetitionLicencesForm(request.POST or None,
                                               region=region)
        formTeams = CompetitionTeamsForm(request.POST or None, region=region)

        if request.method == "POST":
            if formCompetition.is_valid() and formConditions.is_valid(
            ) and formLicences.is_valid() and formTeams.is_valid():
                formCompetition.save()
                formConditions.save()
                formLicences.save()
                formTeams.save()

                return manageCompetition(request, competition.Type.id)

        return render(
            request, 'competitionConditions.html', {
                'headerDto': headerDto,
                'formCompetition': formCompetition,
                'formConditions': formConditions,
                'formLicences': formLicences,
                'formTeams': formTeams
            })

    return redirect('/')
コード例 #16
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def newEdition(request, competitionId):
    user = PermissionsManager.getPermissionsForUser(request.user)
    competition = CompetitionManager.getCompetitionTypeById(competitionId)
    region = competition.Region

    if not PermissionsManager.canCreateEdition(user, region.id):
        return redirect('/')

    if request.method == "GET":
        headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
        formCompetition = CompetitionEditionForm()
        formConditions = CompetitionConditionsForm()
        formLicences = CompetitionLicencesForm(region=region)
        formTeams = CompetitionTeamsForm(region=region)

        return render(
            request, 'competitionConditions.html', {
                'headerDto': headerDto,
                'formCompetition': formCompetition,
                'formConditions': formConditions,
                'formLicences': formLicences,
                'formTeams': formTeams
            })

    elif request.method == "POST":
        edition = Edition()

        formCompetition = CompetitionEditionForm(request.POST,
                                                 instance=edition)
        formConditions = CompetitionConditionsForm(request.POST)
        formLicences = CompetitionLicencesForm(request.POST, region=region)
        formTeams = CompetitionTeamsForm(request.POST, region=region)

        print(formCompetition.is_valid())
        print(formConditions.is_valid())
        print(formLicences.is_valid())
        print(formCompetition.is_valid())

        if formCompetition.is_valid() and formConditions.is_valid(
        ) and formLicences.is_valid() and formTeams.is_valid():
            conditions = formConditions.save(commit=False)
            edition = formCompetition.save(commit=False)

            edition.Conditions = conditions
            edition.save()

            edition.Licences = formLicences.save(commit=False)
            edition.Teams = formTeams.save(commit=False)

            edition.save()

            return manageCompetition(request, competition.Type.id)

        else:
            return render(
                request, 'competitionConditions.html', {
                    'headerDto': headerDto,
                    'formCompetition': formCompetition,
                    'formConditions': formConditions,
                    'formLicences': formLicences,
                    'formTeams': formTeams
                })
コード例 #17
0
def selectLicences(request, player):
	user = PermissionsManager.getPermissionsForUser(request.user)
	headerDto = PermissionsManager.getUserHeaderDto(user).getDto()
	player = PlayerManager.getPlayerById(playerId)
コード例 #18
0
ファイル: views.py プロジェクト: Leuzi/FAFAWeb
def landingPage(request, user):

    headerDto = PermissionsManager.getUserHeaderDto(user).getDto()

    return render(request, 'index.html', {'headerDto': headerDto})