Permalink
Browse files

fix delete project api url

  • Loading branch information...
James Burns
James Burns committed Jul 27, 2012
1 parent 66de1dc commit 2881d58f22bd9a186c6385da0c4aef2da364561b
Showing with 53 additions and 3 deletions.
  1. +52 −2 src/Zeega/ApiBundle/Controller/ProjectsController.php
  2. +1 −1 web/js/ux/zeega.ux.site.js
@@ -69,19 +69,69 @@ public function putProjectsAction($projectId)
throw $this->createNotFoundException('Unable to find the Project with the id ' + $projectId);
}
+ error_log("getItemId",0);
+ error_log($project->getItemId(),0);
+
+ if (is_null($project->getItemId()))
+ {
+ error_log("getItemId was null",0);
+ // create new item
+ // should this be a call to ItemsController->populateItemWithRequestData, so as not to set Item data outside the ItemsController ?
+ $user = $this->get('security.context')->getToken()->getUser();
+
+ $item = new Item();
+ $item->setDateCreated(new \DateTime("now"));
+ $item->setChildItemsCount(0);
+ $item->setUser($user);
+
+ $dateUpdated = new \DateTime("now");
+ $dateUpdated->add(new \DateInterval('PT2M'));
+
+ $item->setDateUpdated($dateUpdated);
+ $item->setUri($projectId);
+ $item->setAttributionUri("http://beta.zeega.org/item_id");
+ $item->setMediaType("project");
+ $item->setLayerType("project");
+ $item->setArchive("zeega");
+ $item->setMediaCreatorUsername("");
+ $item->setPublished(1);
+ //$item->setIndexed(false);
+
+ $item->setEnabled(true);
+ $em->persist($item);
+ $em->flush();
+ }else{
+ error_log("getItemId was not null",0);
+ // fetch associated item
+ $item = $this->getDoctrine()->getRepository('ZeegaItemBundle:Item')->find($request->request->get('item_id'));
+ }
+ // create json item for project
+ // update item.text with json
+
+ // update date_published
$title = $request_data->get('title');
$tags = $request_data->get('tags');
$coverImage = $request_data->get('cover_image');
$authors = $request_data->get('authors');
$published = $request_data->get('published');
- $estimatedTime = $request_data->get('estimated_time');
+ $estimatedTime = $request_data->get('estimated_time');
+ $location = $request_data->get('location');
+ $description = $request_data->get('description');
if(isset($title)) $project->setTitle($title);
if(isset($authors)) $project->setAuthors($authors);
if(isset($coverImage)) $project->setCoverImage($coverImage);
if(isset($tags)) $project->setTags($tags);
if(isset($published)) $project->setPublished($published);
if(isset($estimatedTime)) $project->setEstimatedTime($estimatedTime);
-
+ if(isset($location)) $project->setLocation($location);
+ if(isset($description)) $project->setDescription($description);
+
+
+ error_log("final item_id",0);
+ error_log($item->getId(),0);
+
+ $project->setItemId($item->getId());
+
$project->setDateUpdated(new \DateTime("now"));
$em = $this->getDoctrine()->getEntityManager();
@@ -23,7 +23,7 @@ $(document).ready(function() {
var id =$(this).data('id');
$('.project-'+id).fadeOut();
$.ajax({
- url: sessionStorage.getItem('hostname') + sessionStorage.getItem('directory') +'projects/'+id,
+ url: sessionStorage.getItem('hostname') + sessionStorage.getItem('directory') +'api/projects/'+id,
type: 'DELETE',
success: function(){
console.log('done');

0 comments on commit 2881d58

Please sign in to comment.