Skip to content

Commit

Permalink
Fix project icons
Browse files Browse the repository at this point in the history
Signed-off-by: Walker Crouse <walkercrouse@hotmail.com>
  • Loading branch information
windy1 committed Dec 31, 2016
1 parent 02aec54 commit d3eec82
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/project/Projects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class Projects @Inject()(stats: StatTracker,
implicit override val service: ModelService)
extends BaseController {

implicit val fileManager = factory.fileManager

private val self = controllers.project.routes.Projects

private def SettingsEditAction(author: String, slug: String)
Expand Down
19 changes: 18 additions & 1 deletion app/models/project/ProjectSettings.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models.project

import java.nio.file.Files
import java.nio.file.Files._
import java.sql.Timestamp

import db.impl.ProjectSettingsTable
Expand All @@ -9,12 +11,15 @@ import form.project.ProjectSettingsForm
import models.user.Notification
import models.user.role.ProjectRole
import ore.permission.role.RoleTypes
import ore.project.io.ProjectFileManager
import ore.project.{Categories, ProjectOwned}
import ore.user.notification.NotificationTypes
import play.api.Logger
import play.api.i18n.MessagesApi
import util.StringUtils._

import scala.collection.JavaConverters._

/**
* Represents a [[Project]]'s settings.
*
Expand Down Expand Up @@ -115,7 +120,8 @@ case class ProjectSettings(override val id: Option[Int] = None,
* @param messages MessagesApi instance
*/
//noinspection ComparingUnrelatedTypes
def save(project: Project, formData: ProjectSettingsForm)(implicit messages: MessagesApi) = {
def save(project: Project, formData: ProjectSettingsForm)(implicit messages: MessagesApi,
fileManager: ProjectFileManager) = {
Logger.info("Saving project settings")
Logger.info(formData.toString)

Expand All @@ -130,6 +136,17 @@ case class ProjectSettings(override val id: Option[Int] = None,
// Update the owner if needed
formData.ownerId.find(_ != project.ownerId).foreach(ownerId => project.owner = this.userBase.get(ownerId).get)

// Update icon
if (formData.updateIcon) {
fileManager.getPendingIconPath(project).foreach { pendingPath =>
val iconDir = fileManager.getIconDir(project.ownerName, project.name)
if (notExists(iconDir))
createDirectories(iconDir)
list(iconDir).iterator().asScala.foreach(delete)
move(pendingPath, iconDir.resolve(pendingPath.getFileName))
}
}

// Handle member changes
if (project.isDefined) {
// Add new roles
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "ore"

version := "1.1.2"
version := "1.1.3"

lazy val `ore` = (project in file(".")).enablePlugins(PlayScala)

Expand Down

0 comments on commit d3eec82

Please sign in to comment.