Skip to content
Snippets Groups Projects
Commit 979ad31d authored by Jeremy Guiselin's avatar Jeremy Guiselin
Browse files

begin env prod for ansible + delete pack + add league on device

parent 00ed6a76
Branches
No related tags found
No related merge requests found
Showing
with 164 additions and 409 deletions
mysql_databases:
- name: betskills
collation: utf8_general_ci
encoding: utf8
\ No newline at end of file
apache_vhosts:
- servername: "betskills.dev"
documentroot: "/var/www/betskills/backend/web"
extra_parameters: |
SetEnv APPLICATION_ENV "development"
php_packages: php_packages:
- php7.0-common - php7.0-common
- php7.0-cli - php7.0-cli
......
apache_vhosts:
- servername: "betskills.dev"
documentroot: "/var/www/betskills/backend/web"
extra_parameters: |
SetEnv APPLICATION_ENV "development"
mysql_databases:
- name: betskills
collation: utf8_general_ci
encoding: utf8
\ No newline at end of file
apache_vhosts:
- servername: "backend.betskills.com 213.186.33.40:8080"
documentroot: "/var/www/betskills/backend/web"
extra_parameters: |
SetEnv APPLICATION_ENV "production"
mysql_databases:
- name: betskilltsadmin
collation: utf8_general_ci
encoding: utf8
\ No newline at end of file
[env-prod:children]
app-db
app-web
[app-db]
default ansible_ssh_host=213.186.33.40 ansible_ssh_port=22 ansible_ssh_user=root
[app-web]
default ansible_ssh_host=213.186.33.40 ansible_ssh_port=22 ansible_ssh_user=root
\ No newline at end of file
{"virtualbox":{"vagrant-root":{"id":"vagrant-root","owner":"www-data","mount_options":["dmode=775","fmode=775"],"guestpath":"/var/www/betskills/backend","hostpath":"/private/var/www/betskills/backend","disabled":false,"__vagrantfile":true}}} {"virtualbox":{"vagrant-root":{"id":"vagrant-root","owner":"www-data","mount_options":["dmode=775","fmode=775"],"guestpath":"/var/www/betskills/backend","hostpath":"/Users/jeremyguiselin/Projects/betskills/backend","disabled":false,"__vagrantfile":true}}}
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ imports: ...@@ -10,7 +10,7 @@ imports:
parameters: parameters:
locale: fr locale: fr
team_directory: '%kernel.root_dir%/../web/img/application/team' team_directory: '%kernel.root_dir%/../web/img/application/team'
pack_directory: '%kernel.root_dir%/../web/img/application/pack' league_directory: '%kernel.root_dir%/../web/img/application/league'
framework: framework:
#esi: ~ #esi: ~
......
...@@ -38,33 +38,22 @@ class DefaultController extends FOSRestController ...@@ -38,33 +38,22 @@ class DefaultController extends FOSRestController
} }
/**
* @return Response
*/
public function getPacksAction()
{
$view = View::create()
->setStatusCode(200)
->setData($this->getPackRepository()->findAll());
return $this->handleView($view);
}
/** /**
* @param string $sport * @param string $sport
* @return Response * @return Response
* *
* GET Route annotation. * GET Route annotation.
* @Get("/packs/{sport}") * @Get("/leagues/{sport}")
*/ */
public function getPacksBySportAction(string $sport) public function getLeaguesBySportAction(string $sport)
{ {
try { try {
$packs = $this->getPackRepository()->findPacksBySport($sport); $leagues = $this->getLeagueRepository()->findBy([
'sport' => $sport
]);
$view = View::create() $view = View::create()
->setStatusCode(200) ->setStatusCode(200)
->setData($packs); ->setData($leagues);
return $this->handleView($view); return $this->handleView($view);
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -75,8 +64,6 @@ class DefaultController extends FOSRestController ...@@ -75,8 +64,6 @@ class DefaultController extends FOSRestController
return $this->handleView($view); return $this->handleView($view);
} }
} }
/** /**
...@@ -243,11 +230,6 @@ class DefaultController extends FOSRestController ...@@ -243,11 +230,6 @@ class DefaultController extends FOSRestController
return $this->getDoctrine()->getRepository('BackendBundle:League'); return $this->getDoctrine()->getRepository('BackendBundle:League');
} }
private function getPackRepository()
{
return $this->getDoctrine()->getRepository('BackendBundle:Pack');
}
private function getLogger() private function getLogger()
{ {
return $this->get('logger'); return $this->get('logger');
......
...@@ -21,7 +21,7 @@ class EntityBrowserController extends Controller ...@@ -21,7 +21,7 @@ class EntityBrowserController extends Controller
* @param int $page * @param int $page
* @return Response * @return Response
* *
* @Route("/admin/{name}/list/{page}", requirements={"name" = "league|prediction|pack|team"}) * @Route("/admin/{name}/list/{page}", requirements={"name" = "league|prediction|team"})
*/ */
public function listAction(string $name, Request $request, int $page) public function listAction(string $name, Request $request, int $page)
{ {
...@@ -64,7 +64,7 @@ class EntityBrowserController extends Controller ...@@ -64,7 +64,7 @@ class EntityBrowserController extends Controller
* @param Request $request * @param Request $request
* @return Response * @return Response
* *
* @Route("/admin/{name}/new", requirements={"name" = "league|prediction|pack|team"}) * @Route("/admin/{name}/new", requirements={"name" = "league|prediction|team"})
*/ */
public function newAction(string $name, Request $request) public function newAction(string $name, Request $request)
{ {
...@@ -104,7 +104,7 @@ class EntityBrowserController extends Controller ...@@ -104,7 +104,7 @@ class EntityBrowserController extends Controller
* @param Request $request * @param Request $request
* @return Response * @return Response
* *
* @Route("/admin/{name}/edit/{id}", requirements={"name" = "league|prediction|pack|team", "id"}) * @Route("/admin/{name}/edit/{id}", requirements={"name" = "league|prediction|team", "id"})
*/ */
public function editAction(string $name, int $id, Request $request) public function editAction(string $name, int $id, Request $request)
{ {
...@@ -142,7 +142,7 @@ class EntityBrowserController extends Controller ...@@ -142,7 +142,7 @@ class EntityBrowserController extends Controller
* @param Request $request * @param Request $request
* @return JsonResponse * @return JsonResponse
* *
* @Route("/admin/{name}/delete", requirements={"name" = "league|prediction|pack|team"}) * @Route("/admin/{name}/delete", requirements={"name" = "league|prediction|team"})
*/ */
public function deleteAction(string $name, Request $request) public function deleteAction(string $name, Request $request)
{ {
...@@ -211,7 +211,7 @@ class EntityBrowserController extends Controller ...@@ -211,7 +211,7 @@ class EntityBrowserController extends Controller
private function setPicture(string $name, $element) private function setPicture(string $name, $element)
{ {
if (in_array($name, ['team', 'pack'])) { if (in_array($name, ['team', 'league'])) {
/** @var File $file */ /** @var File $file */
$file = $element->getPicture(); $file = $element->getPicture();
......
<?php
/**
* Created by PhpStorm.
* User: jeremyguiselin
* Date: 19/12/2016
* Time: 10:36
*/
namespace BackendBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* LeagueOnDevice
*
* @ORM\Table(name="league_on_device")
* @ORM\Entity(repositoryClass="BackendBundle\Repository\LeagueOnDeviceRepository")
*/
class LeagueOnDevice
{
const STATUS_UNLOCK = 'unlock';
const STATUS_LOCK = 'lock';
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var Device
*
* @ORM\ManyToOne(targetEntity="BackendBundle\Entity\Device")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $device;
/**
* @var League
*
* @ORM\ManyToOne(targetEntity="BackendBundle\Entity\League")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $league;
/**
* @var string
*
* @ORM\Column(name="status", type="string", length=255)
*/
private $status = self::STATUS_LOCK;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return Device
*/
public function getDevice()
{
return $this->device;
}
/**
* @param Device $device
*/
public function setDevice($device)
{
$this->device = $device;
}
/**
* @return League
*/
public function getLeague()
{
return $this->league;
}
/**
* @param League $league
*/
public function setLeague($league)
{
$this->league = $league;
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* @param string $status
*/
public function setStatus($status)
{
$this->status = $status;
}
}
\ No newline at end of file
...@@ -31,7 +31,7 @@ class Notification ...@@ -31,7 +31,7 @@ class Notification
/** /**
* @var string * @var string
* *
* @ORM\Column(name="content", type="text") * @ORM\Column(type="text")
*/ */
private $frenchContent; private $frenchContent;
...@@ -45,7 +45,7 @@ class Notification ...@@ -45,7 +45,7 @@ class Notification
/** /**
* @var string * @var string
* *
* @ORM\Column(name="content", type="text") * @ORM\Column(type="text")
*/ */
private $englishContent; private $englishContent;
......
<?php
namespace BackendBundle\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Pack
*
* @ORM\Table(name="pack")
* @ORM\Entity(repositoryClass="BackendBundle\Repository\PackRepository")
*/
class Pack
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var int
*
* @ORM\Column(name="priceInCents", type="integer")
*/
private $priceInCents;
/**
* @var League[]
* @ORM\ManyToMany(targetEntity="League", cascade={"all"}, fetch="EAGER")
* @ORM\JoinTable(name="pack_leagues",
* joinColumns={@ORM\JoinColumn(name="pack_id", referencedColumnName="id", onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="league_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*/
private $leagues;
/**
* @ORM\Column(name="picture", type="string", length=255)
*
* @Assert\NotBlank(message="Veuillez uploader une image de l'équipe")
* @Assert\File(mimeTypes={"image/jpeg", "image/png"})
*/
private $picture;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return Pack
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set priceInCents
*
* @param integer $priceInCents
*
* @return Pack
*/
public function setPriceInCents($priceInCents)
{
$this->priceInCents = $priceInCents;
return $this;
}
/**
* Get priceInCents
*
* @return int
*/
public function getPriceInCents()
{
return $this->priceInCents;
}
/**
* @return League[]
*/
public function getLeagues()
{
return $this->leagues;
}
/**
* @param Collection $leagues
*/
public function setLeagues(Collection $leagues)
{
$this->leagues = $leagues;
}
public function removeLeagues(Collection $leagues)
{
foreach ($leagues as $league) {
$this->leagues->removeElement($league);
}
}
public function addLeagues(Collection $leagues)
{
foreach ($leagues as $league) {
$this->leagues->add($league);
}
}
/**
* @return mixed
*/
public function getPicture()
{
return $this->picture;
}
/**
* @param mixed $picture
*/
public function setPicture($picture)
{
$this->picture = $picture;
}
}
<?php
namespace BackendBundle\Form;
use BackendBundle\Form\Type\FloatType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PackType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, [
'label' => 'Nom',
])
->add('priceInCents', FloatType::class, [
'label' => 'Prix (en centimes)'
])
->add('leagues', EntityType::class, [
'label' => 'Ligues',
'class' => 'BackendBundle\Entity\League',
'choice_label' => 'name',
'multiple' => true,
'expanded' => false
])
->add('picture', FileType::class, [
'label' => 'Image',
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'BackendBundle\Entity\Pack',
'csrf_protection' => false,
]);
}
public function getName()
{
return 'backend_bundle_pack_type';
}
}
<?php
namespace BackendBundle\Repository;
use BackendBundle\Entity\Pack;
use Doctrine\ORM\EntityRepository;
/**
* PackRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class PackRepository extends EntityRepository
{
public function alreadyExists(Pack $pack) : bool
{
return $this->findOneBy([
'name' => $pack->getName()
]) !== null;
}
public function getAll()
{
$qb = $this->createQueryBuilder('p');
$qb->select('p');
return $qb;
}
public function findPacksBySport(string $sport)
{
$qb = $this->createQueryBuilder('p');
$qb
->select('p')
->join('p.leagues', 'l', 'WITH', 'l.sport = :sport')
->setParameter('sport', $sport);
return $qb->getQuery()->getResult();
}
}
\ No newline at end of file
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="{{ path('backend_entitybrowser_list', {'name': 'league', 'page': 1}) }}">Gestion des ligues</a></li> <li><a href="{{ path('backend_entitybrowser_list', {'name': 'league', 'page': 1}) }}">Gestion des ligues</a></li>
<li><a href="{{ path('backend_entitybrowser_list', {'name': 'prediction', 'page': 1}) }}">Gestion des prédictions</a></li> <li><a href="{{ path('backend_entitybrowser_list', {'name': 'prediction', 'page': 1}) }}">Gestion des prédictions</a></li>
<li><a href="{{ path('backend_entitybrowser_list', {'name': 'pack', 'page': 1}) }}">Gestion des packs</a></li>
<li><a href="{{ path('backend_entitybrowser_list', {'name': 'team', 'page': 1}) }}">Gestion des équipes</a></li> <li><a href="{{ path('backend_entitybrowser_list', {'name': 'team', 'page': 1}) }}">Gestion des équipes</a></li>
<li><a href="{{ path('backend_notification_list', {'page': 1}) }}">Notifications</a></li> <li><a href="{{ path('backend_notification_list', {'page': 1}) }}">Notifications</a></li>
</ul> </ul>
......
{% extends '@Backend/layout/dashboard.html.twig' %}
{% block title %}Gestion de {{ name }}{% endblock %}
{% block stylesheets %}
<script src="{{ asset('js/selectize.min.js') }}"></script>
{% endblock %}
{% block subcontent %}
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<h3 class="text-center text-primary">Ajouter un nouveau ou éditer un {{ name | trans }}</h3>
{{ form_start(form, {'attr': {'class': 'form-horizontal'}}) }}
<div class="form-group is-empty has-primary">
{{ form_label(form.name, null, {'label_attr': {'class': "col-sm-2 control-label"}}) }}
<div class="col-sm-10">
{{ form_widget(form.name, {'attr' : {'class': "form-control"}}) }}
</div>
{{ form_errors(form.name) }}
</div>
<div class="form-group is-empty has-primary">
{{ form_label(form.priceInCents, null, {'label_attr': {'class': "col-sm-2 control-label"}}) }}
<div class="col-sm-10">
{{ form_widget(form.priceInCents, {'attr' : {'class': "form-control"}}) }}
</div>
{{ form_errors(form.priceInCents) }}
</div>
<div class="form-group">
{{ form_label(form.leagues, null, {'label_attr': {'class': "col-sm-2 control-label"}}) }}
<div class="col-sm-10">
<div class="checkbox">
{{ form_widget(form.leagues, {'attr' : {'class' : "js-example-basic-multiple js-states form-control"}}) }}
{{ form_errors(form.leagues) }}
</div>
</div>
</div>
<div class="form-group is-empty has-primary">
{{ form_label(form.picture, null, {'label_attr': {'class': "col-sm-2 control-label"}}) }}
<div class="col-sm-10">
{{ form_widget(form.picture, {'attr' : {'class': "form-control"}}) }}
</div>
{{ form_errors(form.picture) }}
</div>
<button type="submit" class="modal-action modal-close waves-effect waves-green waves-light btn">Ajouter</button>
{{ form_end(form, {'render_rest': false}) }}
</div>
</div>
{% endblock %}
{% block javascripts %}
<script type="text/javascript">
$('select').selectize();
</script>
{% endblock %}
\ No newline at end of file
{% extends '@Backend/layout/dashboard.html.twig' %}
{% block title %}Liste de {{ name | trans }}{% endblock %}
{% block subcontent %}
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
{% include '@Backend/entity-browser/buttons.html.twig' %}
<table class="table table-striped" cellspacing="0" width="50%">
<thead>
<tr>
<th>#</th>
<th>Nom</th>
<th>Prix</th>
<th>Ligues</th>
<th>Modifier</th>
<th>Selectionner</th>
</tr>
</thead>
<tbody>
{% for element in elements %}
{% set leagues = [] %}
{% for league in element.leagues %}
{% set leagues = leagues|merge([league.name]) %}
{% endfor %}
<tr id="{{ element.id }}">
<td>{{ element.id }}</td>
<td>{{ element.name }}</td>
<td>{{ element.priceInCents / 100 }}</td>
<td>{{ leagues|join(', ') }}</td>
<td><a href="{{ path('backend_entitybrowser_edit', {'name': name, 'id': element.id}) }}" class="btn btn-info">Modifier<div class="ripple-container"></div></a></td>
<td>
<div class="checkbox">
<label>
<input type="checkbox" data-id="{{ element.id }}">
</label>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include '@Backend/entity-browser/paginator.html.twig' %}
</div>
</div>
{% endblock %}
{% block javascripts %}
<script src="{{ asset('js/ajax-select-and-delete.js') }}"></script>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment