Skip to content

Commit

Permalink
Merge pull request #7 from Darkenend/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Darkenend authored May 24, 2020
2 parents 71a32f0 + dc4128c commit 84d95e8
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/Controller/ResultProcessingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ public function insertAuto(Race $id): Response
}
}
$this->getDoctrine()->getRepository(Race::class)->find($id)->setComplete(true);
$championship = $this->getDoctrine()->getRepository(Race::class)->find($id)->getChampionshipId();
$pointsEntrylists = $this->getDoctrine()->getRepository(Race::class)->find($id)->getTeamEntryLists()->slice(0,10);
$pointsArray = [25, 18, 15, 12, 10, 8, 6, 4, 2, 1];
$count = 0;
foreach ($pointsEntrylists as $entrylist) {
$championshipEntry = $this->getDoctrine()->getRepository(ChampionshipEntries::class)->findOneBy([
'championship'=>$championship,
'team'=>$entrylist->getTeamId()
]);
$championshipEntry->setPoints($championshipEntry->getPoints()+$pointsArray[$count]);
$count++;
}
$this->getDoctrine()->getManager()->flush();
unlink($filepath);
unlink($_SERVER['APP_FOLDER']."\\results\\".$results_directory[2]);
Expand Down
31 changes: 31 additions & 0 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@

namespace App\Controller;

use App\Entity\User;
use App\Form\RegisterType;
use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class SecurityController extends AbstractController
{
private $passwordEncoder;

public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{
$this->passwordEncoder = $passwordEncoder;
}
/**
* @Route("/login", name="app_login")
*/
Expand All @@ -34,4 +44,25 @@ public function logout()
{
throw new LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}

/**
* @Route("/register", name="app_register")
*/
public function register(?Request $request): Response
{
$user = new User();
$form = $this->createForm(RegisterType::class, $user);
if (isset($request)) $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$userpassword = $form->getData();
$user->setPassword($this->passwordEncoder->encodePassword($user, $userpassword->getPassword()));
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
return $this->redirectToRoute('app_login');
}
return $this->render('security/register.html.twig', [
'form' => $form->createView()
]);
}
}
47 changes: 47 additions & 0 deletions src/Form/RegisterType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Form;

use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class RegisterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class)
->add('password', PasswordType::class)
->add('name', TextType::class, [
'attr' => [
'maxlength' => '64'
]
])
->add('lastname', TextType::class, [
'attr' => [
'maxlength' => '128'
]
])
->add('steamid', TextType::class, [
'label' => 'Your SteamID64',
'attr' => [
'maxlength' => '18'
]
])
->add('submit', SubmitType::class)
;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}
11 changes: 7 additions & 4 deletions templates/home/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<div id="carouselScreenshots" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" data-interval="2000">
<img src="{{ asset(img_1_code) }}" class="d-block w-100" alt="Racing League Manager">
<img src="{{ asset(img_1_code) }}" alt="Racing League Manager" style="max-width: 50%; display: block; margin:auto">
</div>
<div class="carousel-item" data-interval="2000">
<img src="{{ asset(img_2_code) }}" class="d-block w-100" alt="Racing League Manager">
<img src="{{ asset(img_2_code) }}" alt="Racing League Manager" style="max-width: 50%; display: block; margin:auto">
</div>
<div class="carousel-item" data-interval="2000">
<img src="{{ asset(img_3_code) }}" class="d-block w-100" alt="Racing League Manager">
<img src="{{ asset(img_3_code) }}" alt="Racing League Manager" style="max-width: 50%; display: block; margin:auto">
</div>
</div>
<a class="carousel-control-prev" href="#carouselScreenshots" role="button" data-slide="prev">
Expand All @@ -39,8 +39,11 @@
<span class="sr-only">Next</span>
</a>
</div>
<a href="{{ path('app_login') }}" class="btn btn-success btn-lg mt-3" role="button">
<a href="{{ path('app_login') }}" class="btn btn-success btn-lg mt-3 float-left" role="button">
Login
</a>
<a href="{{ path('app_register') }}" class="btn btn-success btn-lg mt-3 float-right" role="button">
Register
</a>
</div>
{% endblock %}
49 changes: 49 additions & 0 deletions templates/security/register.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% extends 'base.html.twig' %}

{% block title %}RLM | Register{% endblock %}

{% block body %}
<div class="row text-center">
<div class="col">
<h1 class="display-1">
Registration
</h1>
</div>
</div>
{{ form_start(form) }}
<div class="row">
<div class="col col-md-6 col-lg-3 offset-lg-2">
{{ form_row(form.name)}}
</div>
<div class="col col-md-6 col-lg-3 offset-lg-2">
{{ form_row(form.lastname)}}
</div>
</div>
<div class="row">
<div class="col col-md-6 col-lg-3 offset-lg-2">
{{ form_row(form.email)}}
</div>
<div class="col col-md-6 col-lg-3 offset-lg-2">
{{ form_row(form.password)}}
</div>
</div>
<div class="row">
<div class="col col-md-6 col-lg-3 offset-lg-2">
{{ form_row(form.steamid)}}
</div>
<div class="col col-md-6 col-lg-3 offset-lg-2 my-auto">
If you don't know where to find your SteamID64, you can go <a href="https://steamidfinder.com">here</a>, and search for your profile.
</div>
</div>
<div class="row text-center">
<div class="col-12">
{{ form_row(form.submit) }}
</div>
<div class="col-12">
<a href="{{ path('slash') }}">
Go back to the homepage
</a>
</div>
</div>
{{ form_end(form) }}
{% endblock %}

0 comments on commit 84d95e8

Please sign in to comment.