Skip to content

Commit f267c26

Browse files
brendanx67claude
andcommitted
Removed rating and review system from Tool Store
* Deleted RatingManager.java and Rating.java model class * Removed SubmitRatingAction and DeleteRatingAction from controller * Removed review forms, rating display, and rating CSS from both JSPs * Removed initRatingSlider from functions.js * Fixed InsertAction NavTree to use flat breadcrumb structure Co-Authored-By: Claude <[email protected]>
1 parent 77108da commit f267c26

8 files changed

Lines changed: 5 additions & 831 deletions

File tree

SkylineToolsStore/src/org/labkey/skylinetoolsstore/RatingManager.java

Lines changed: 0 additions & 129 deletions
This file was deleted.

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreController.java

Lines changed: 2 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
import org.labkey.api.view.UnauthorizedException;
7979
import org.labkey.api.webdav.WebdavResource;
8080
import org.labkey.api.webdav.WebdavService;
81-
import org.labkey.skylinetoolsstore.model.Rating;
8281
import org.labkey.skylinetoolsstore.model.SkylineTool;
8382
import org.labkey.skylinetoolsstore.view.SkylineToolDetails;
8483
import org.labkey.skylinetoolsstore.view.SkylineToolStoreUrls;
@@ -613,7 +612,8 @@ else if (!getContainer().hasPermission(getUser(), InsertPermission.class))
613612
@Override
614613
public void addNavTrail(NavTree root)
615614
{
616-
root.addChild(getToolStoreNav(getContainer())).addChild("Upload Tool", getURL());
615+
root.addChild(getToolStoreNav(getContainer()));
616+
root.addChild("Upload Tool", getURL());
617617
}
618618

619619
public ActionURL getURL()
@@ -645,151 +645,6 @@ private void redirectToToolStoreContainer(SkylineTool tool, ActionURL originalUr
645645
}
646646
}
647647

648-
@RequiresNoPermission
649-
public class SubmitRatingAction extends AbstractController implements PermissionCheckable
650-
{
651-
private static final String NO_TITLE = "You did not enter a valid title.";
652-
private static final String NO_RATING = "You did not submit a valid rating. Ratings must be between 1 and 5.";
653-
private static final String NO_REVIEW = "You did not submit a valid review.";
654-
private static final String ALREADY_REVIEWED = "You have already left a review for this tool.";
655-
656-
public SubmitRatingAction()
657-
{
658-
}
659-
660-
@Override
661-
protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
662-
{
663-
final User user = getUser();
664-
final String toolIdString = httpServletRequest.getParameter("toolId");
665-
int toolId = (toolIdString != null && !toolIdString.isEmpty()) ? Integer.parseInt(toolIdString) : -1;
666-
667-
final String ratingIdString = httpServletRequest.getParameter("ratingId");
668-
int ratingId;
669-
try {
670-
ratingId = (ratingIdString != null && !ratingIdString.isEmpty()) ? Integer.parseInt(ratingIdString) : -1;
671-
} catch(Exception e) {
672-
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
673-
}
674-
Rating rating = (ratingId < 0) ? null : RatingManager.get().getRatingById(ratingId);
675-
final SkylineTool tool = SkylineToolsStoreManager.get().getTool((toolId >= 0) ? toolId : rating.getToolId());
676-
677-
final String ratingValueString = httpServletRequest.getParameter("value");
678-
final int ratingValue;
679-
try {
680-
ratingValue = Integer.parseInt(ratingValueString);
681-
} catch(Exception e) {
682-
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
683-
}
684-
final String ratingTitle = httpServletRequest.getParameter("title");
685-
final String review = httpServletRequest.getParameter("review");
686-
687-
if (ratingId < 0 && RatingManager.get().userLeftRating(tool.getIdentifier(), getUser()))
688-
{
689-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
690-
ALREADY_REVIEWED);
691-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "hideForm",
692-
true);
693-
}
694-
else if (ratingTitle == null || ratingTitle.isEmpty())
695-
{
696-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
697-
NO_TITLE);
698-
}
699-
else if (ratingValue < 1 || ratingValue > 5)
700-
{
701-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
702-
NO_RATING);
703-
}
704-
else if (review == null || review.isEmpty())
705-
{
706-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
707-
NO_REVIEW);
708-
}
709-
else if (user.isGuest())
710-
{
711-
throw new Exception();
712-
}
713-
else if (tool == null || (ratingId >= 0 && rating == null))
714-
{
715-
throw new Exception();
716-
}
717-
else
718-
{
719-
if (rating == null)
720-
{
721-
// Adding new rating
722-
rating = new Rating(ratingValue, review, toolId, ratingTitle);
723-
rating.setContainer(getContainer().getId());
724-
RatingManager.get().insertRating(user, rating);
725-
}
726-
else
727-
{
728-
// Editing existing rating
729-
if (rating.getCreatedBy() != user.getUserId() && !getUser().hasSiteAdminPermission())
730-
{
731-
throw new Exception();
732-
}
733-
rating.setTitle(ratingTitle);
734-
rating.setRating(ratingValue);
735-
rating.setReview(review);
736-
RatingManager.get().editRating(rating, user);
737-
}
738-
return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool));
739-
}
740-
741-
if (toolId >= 0)
742-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "toolId", toolId);
743-
if (ratingId >= 0)
744-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "ratingId", ratingId);
745-
if (ratingTitle != null)
746-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formTitle", ratingTitle);
747-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formValue", ratingValue);
748-
if (review != null)
749-
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formReview", review);
750-
751-
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
752-
}
753-
754-
@Override
755-
public void checkPermissions() throws UnauthorizedException
756-
{
757-
758-
}
759-
}
760-
761-
@RequiresNoPermission
762-
public class DeleteRatingAction extends AbstractController implements PermissionCheckable
763-
{
764-
public DeleteRatingAction()
765-
{
766-
}
767-
768-
@Override
769-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
770-
{
771-
int id = NumberUtils.toInt(httpServletRequest.getParameter("id"), -1);
772-
int user = getUser().getUserId();
773-
final Rating rating = RatingManager.get().getRatingById(id);
774-
if(rating != null)
775-
{
776-
if (user == rating.getCreatedBy() || getUser().hasSiteAdminPermission())
777-
RatingManager.get().deleteRating(id);
778-
else
779-
throw new Exception();
780-
}
781-
782-
final SkylineTool tool = SkylineToolsStoreManager.get().getTool(rating.getToolId());
783-
return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool));
784-
}
785-
786-
@Override
787-
public void checkPermissions() throws UnauthorizedException
788-
{
789-
790-
}
791-
}
792-
793648
@RequiresNoPermission
794649
public class InsertSupplementAction extends AbstractController implements PermissionCheckable
795650
{
@@ -948,7 +803,6 @@ public boolean handlePost(IdForm idForm, BindException errors) throws Exception
948803
// TODO: Should be in a transaction
949804
for (SkylineTool toDelete : SkylineToolsStoreManager.get().getToolsByIdentifier(tool.getIdentifier()))
950805
{
951-
RatingManager.get().deleteRatingsByToolId(toDelete.getRowId());
952806
ContainerManager.delete(toDelete.lookupContainer(), getUser());
953807
}
954808

@@ -1027,7 +881,6 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
1027881
if (tools.length == 1)
1028882
throw new Exception();
1029883

1030-
RatingManager.get().deleteRatingsByToolId(tool.getRowId());
1031884
ContainerManager.delete(tools[0].lookupContainer(), getUser());
1032885

1033886
if (tools.length > 1)

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreSchema.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,4 @@ public TableInfo getTableInfoSkylineTool()
5656
{
5757
return getSchema().getTable("SkylineTool");
5858
}
59-
60-
public TableInfo getTableInfoRating()
61-
{
62-
return getSchema().getTable("Rating");
63-
}
6459
}

0 commit comments

Comments
 (0)