Skip to content

Commit

Permalink
Update album OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Caillau committed Dec 27, 2012
1 parent abd0a4f commit 277d9c0
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 90 deletions.
154 changes: 114 additions & 40 deletions app/Resources/views/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,66 +41,125 @@
<a class="brand" href="#">My Website</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li{% if page is defined %} {% if page == 'home'%} class="active" {% endif %} {% endif %}><a href="{{ path('home') }}"><i class="icon-home icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'gallery'%} class="active" {% endif %} {% endif %}><a href="{{ path('gallery') }}"><i class="icon-picture icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'about'%} class="active" {% endif %} {% endif %}><a href="{{ path('about') }}"><i class="icon-question-sign icon-white"> </i></a></li>
<li><a href="#email" data-toggle="modal"><i class="icon-envelope icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'home'%}
class="active" {% endif %} {% endif %}><a href="{{
path('home') }}" rel="tooltip"
data-placement="bottom" title="Home" id="home"><i class="icon-home icon-white"> </i></a></li>
<li{% if page is defined %} {% if page ==
'gallery'%} class="active" {% endif %} {% endif
%}><a href="{{ path('gallery') }}" id="gallery"
data-placement="bottom" title="Gallery"
rel="tooltip"><i class="icon-picture icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'about'%}
class="active" {% endif %} {% endif %}><a href="{{
path('about') }}"
rel="tooltip" data-placement="bottom"
title="About" id="about"><i class="icon-question-sign icon-white"> </i></a></li>
<li><a href="#calendar-modal" rel="tooltip"
title="Calendar" id="calendar"
data-placement="bottom" data-toggle="modal"><i
class="icon-calendar icon-white"> </i></a></li>
<li><a href="#email-modal" id="email" rel="tooltip"
data-placement="bottom" title="Email" data-toggle="modal"><i class="icon-envelope icon-white"> </i></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div id="email" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Send me an email</h3>
<div id="calendar-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Calendar

{% if is_granted('ROLE_ADMIN') %}
<span class="btn btn-primary" id="calendarAdd">Add</span>
{% endif %}
</h3>
</div>
<div class="modal-body">
<div id="calendarList">
{% render "ChouffeMagicBundle:Event:seeAll" %}
</div>
<div id="calendarForm">
{% render "ChouffeMagicBundle:Event:addForm" %}
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Your Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="[email protected]"><br />
</div>
</div>
</div>

<div id="email-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Send me an email</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Your Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="[email protected]"><br />
</div>
<div class="control-group">
<label class="control-label" for="subject">Subject</label>
<div class="controls">
<select name="subject">
<option value="">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>

</div>
<div class="control-group">
<label class="control-label" for="subject">Subject</label>
<div class="controls">
<select name="subject">
<option value="">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
<div class="control-group">
<label class="control-label" for="content">Content</label>
<div class="controls">
<textarea rows="8" name="content" id="content"></textarea>

</div>
</div>
<div class="control-group">
<label class="control-label" for="content">Content</label>
<div class="controls">
<textarea rows="8" name="content" id="content"></textarea>

</div>
</form>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary">Send email</a>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary">Send email</a>
</div>
</div>

<header id="header1">
<div class="container">
<h1>Paul Caillau ~ {% block main_title %}Home{% endblock %}</h1>
</div>
<div class="container">
<h1>Paul Caillau ~ {% block main_title %}Home{% endblock %}</h1>
</div>
</header>

<div class="container">
<div id="content" class="span9">
{% if app.session.flashbag.get('info') is defined %}
{% for message in app.session.flashbag.get('info') %}
<div class="alert alert-success">
<button type="button" class="close"
data-dismiss="alert">&times;</button>
<h4>Info</h4>
<p>{{ message }}</p>
</div>
{% endfor %}
{% endif %}
{% if app.session.flashbag.get('error') is defined %}
{% for message in app.session.flashbag.get('error') %}
<div class="alert alert-error">
<button type="button" class="close"
data-dismiss="alert">&times;</button>
<h4>Error</h4>
<p>{{ message }}</p>
</div>
{% endfor %}
{% endif %}
{% block body %}
{% endblock %}
</div>
<div class="span2 pull-right">
{% render "ChouffeMagicBundle:Event:agenda" %}
</div>
</div> <!-- /container -->

<!-- Javascript
Expand All @@ -111,6 +170,21 @@
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="{{ asset('js/bootstrap.js') }}"></script>
{% endblock %}
<script>
$(function(){
$('#home').tooltip();
$('#gallery').tooltip();
$('#about').tooltip();
$('#calendar').tooltip();
$('#email').tooltip();
$('#calendarForm').hide();
$('#calendarAdd').click(function(){
$('#calendarForm').toggle();
$('#calendarList').toggle();
});
});
</script>
{% block jquery %}
{% endblock %}

Expand Down
Binary file not shown.
Binary file modified src/Chouffe/MagicBundle/Controller/.NewsController.php.swp
Binary file not shown.
Binary file not shown.
21 changes: 13 additions & 8 deletions src/Chouffe/MagicBundle/Controller/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public function addAction()
$em->persist($album);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'Album saved');
return new Response('1');
$this->get('session')->getFlashBag()->add('info', 'Album added');
return $this->redirect($this->generateUrl('gallery'));
}


return new Response('0');
$this->get('session')->getFlashBag()->add('error', 'Error while saving the album');
return $this->redirect($this->generateUrl('gallery'));
}

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ public function updateAddAction(Album $album)
public function updateAction(Album $album)
{
$form = $this->createForm(new AlbumType, $album);
return $this->render('ChouffeMagicBundle:forms:album.html.twig', array('action' => 'update', 'form' => $form->createView()));
return $this->render('ChouffeMagicBundle:forms:album.html.twig', array('album' => $album, 'action' => 'update', 'form' => $form->createView()));
}

/**
Expand All @@ -120,11 +120,16 @@ public function updateAction(Album $album)
public function deleteAction(Album $album)
{
$em = $this->getDoctrine()->getManager();
foreach( $album->getPhotos() as $photo )
{
$em->remove($photo);
}

$em->remove($album);

$response = new Response('1');
$em->flush();
return $response;

$this->get('session')->getFlashBag()->add('info', 'Album deleted');
return $this->redirect($this->generateUrl('gallery'));
}

}
Expand Down
37 changes: 29 additions & 8 deletions src/Chouffe/MagicBundle/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public function addAction()
$em->persist($event);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'Event saved');
return new Response('1');
$this->get('session')->getFlashBag()->add('info', 'Event saved');
return $this->redirect($this->generateUrl('home'));
}


return new Response('0');
$this->get('session')->getFlashBag()->add('error', 'Error while saving the event');
return $this->redirect($this->generateUrl('home'));
}
/**
* @Secure(roles="ROLE_ADMIN")
Expand All @@ -46,17 +46,17 @@ public function deleteAction(Event $event)
{
$em = $this->getDoctrine()->getManager();
$em->remove($event);

$response = new Response('1');
$em->flush();
return $response;

$this->get('session')->getFlashBag()->add('info', 'Event deleted');
return $this->redirect($this->generateUrl('home'));
}

public function agendaAction()
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('ChouffeMagicBundle:Event');
$eventList = $repo->findAll();
$eventList = $repo->findBy(array(), array('date' => 'desc'));

$event = new Event();
$formEvent = $this->createForm(new EventType, $event);
Expand All @@ -69,4 +69,25 @@ public function seeAction(Event $event)
{
return $this->render('ChouffeMagicBundle:Default:event-zoom.html.twig', array('event' => $event));
}

public function seeAllAction()
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('ChouffeMagicBundle:Event');
$eventList = $repo->findBy(array(), array('date' => 'desc'));

return $this->render('ChouffeMagicBundle:Default:calendar.html.twig', array('eventList' => $eventList));
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function addFormAction()
{
$event = new Event();
$form = $this->createForm(new EventType, $event);

// return new Response('Salut');
return $this->render('ChouffeMagicBundle:forms:event.html.twig', array('form' => $form->createView()));
}
}
19 changes: 11 additions & 8 deletions src/Chouffe/MagicBundle/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public function addAction()
$em->persist($news);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'News added');
return new Response('1');
$this->get('session')->getFlashBag()->add('info', 'News added');
return $this->redirect($this->generateUrl('home'));
}

return new Response('0');
$this->get('session')->getFlashBag()->add('error', 'Error while saving the news');
return $this->redirect($this->generateUrl('home'));
}

/**
Expand All @@ -103,11 +104,12 @@ public function updateAddAction(News $news)
$em->persist($news);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'News added');
return new Response('1');
$this->get('session')->getFlashBag()->add('info', 'News updated');
return $this->redirect($this->generateUrl('home'));
}

return new Response('0');
$this->get('session')->getFlashBag()->add('error', 'Error while updating the news');
return $this->redirect($this->generateUrl('home'));
}

/**
Expand All @@ -127,9 +129,10 @@ public function deleteAction(News $news)
$em = $this->getDoctrine()->getManager();
$em->remove($news);

$response = new Response('1');
$em->flush();
return $response;
$this->get('session')->getFlashBag()->add('info', 'News deleted');

return $this->redirect($this->generateUrl('home'));
}

public function indexAction($name)
Expand Down
18 changes: 9 additions & 9 deletions src/Chouffe/MagicBundle/Controller/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function fetchAction(Photo $photo)
/**
* @Secure(roles="ROLE_ADMIN")
*/
public function addAction(Photo $photo)
public function addAction(Album $album)
{
$photo = new Photo();
$form = $this->createForm(new PhotoType, $photo);
Expand All @@ -61,20 +61,19 @@ public function addAction(Photo $photo)
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);
$photo->setPhoto($photo);

$em = $this->getDoctrine()->getManager();
$photo->addPhoto($photo);
$album->addPhoto($photo);
$em->persist($photo);
$em->persist($photo);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'Photo saved');
return new Response('1');
$this->get('session')->getFlashBag()->add('info', 'Photo added');
return $this->redirect($this->generateUrl('album_see', array('id' => $album->getId())));
}


return new Response('0');
$this->get('session')->getFlashBag()->add('error', 'Error while saving the photo');
return $this->redirect($this->generateUrl('home'));
}

/**
Expand Down Expand Up @@ -117,9 +116,10 @@ public function deleteAction(Photo $photo)
$em = $this->getDoctrine()->getManager();
$em->remove($photo);

$response = new Response('1');
$em->flush();
return $response;

$this->get('session')->getFlashBag()->add('info', 'Photo deleted');
return $this->redirect($this->generateUrl('album_see', array('id' => $photo->getAlbum()->getId())));
}

}
Expand Down
Loading

0 comments on commit 277d9c0

Please sign in to comment.