Skip to content

Commit

Permalink
Merge pull request #725 from socialappslab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
cdparra authored Dec 19, 2017
2 parents 72f1d44 + ff3fe17 commit 49c41e2
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 413 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ dist
/tests
/appcivist-core


public/contributionsFiles/*
conf/play-authenticate/mine.heroku.conf
conf/play-authenticate/mine.local.conf
conf/play-authenticate/smtp.heroku.conf
Expand Down
787 changes: 380 additions & 407 deletions app/controllers/Contributions.java

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/delegates/ContributionsDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ public static List<Contribution> findContributions(Map<String, Object> condition
Expression e = Expr.in(propertyName,cStatuses);
where.add(e);
break;
case "selectedContributions":
List<Integer> selected = (List)value;
where.in("t0.uuid", selected);
default:
if(value instanceof String){
where.ilike(key, ("t0."+(String)value).toLowerCase() + "%");
Expand Down
12 changes: 12 additions & 0 deletions app/models/Contribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public class Contribution extends AppCivistBaseModel {
@Transient
private String documentSimple;

@Transient
@JsonView(Views.Public.class)
List<CustomFieldValue> customFieldValues;

/**
* The find property is an static property that facilitates database query
* creation
Expand Down Expand Up @@ -1554,4 +1558,12 @@ public String getSourceUrl(){
public void setSourceUrl(String sourceUrl){
this.sourceUrl = sourceUrl;
}

public List<CustomFieldValue> getCustomFieldValues() {
return customFieldValues;
}

public void setCustomFieldValues(List<CustomFieldValue> customFieldValues) {
this.customFieldValues = customFieldValues;
}
}
6 changes: 6 additions & 0 deletions app/models/CustomFieldValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public static List<CustomFieldValue> findAllByContainingSpace(Long sid) {
return customFieldValues;
}

public static List<CustomFieldValue> findAllByTargetUUID(String uuid) {
List<CustomFieldValue> customFieldValues = find.where()
.eq("entityTargetUuid", uuid).findList();
return customFieldValues;
}

public static List<CustomFieldValue> findCustomValuesByText (List<Long> ids, String byText, String entityTargetType, CustomFieldDefinition customFieldDefiniton){
//Remove all useless with spaces and replace the others by the logical operator '&'
String words = byText.replaceAll("\\s*$", "").replaceAll("^\\s*", "").replaceAll("\\s+", " ").replaceAll("\\s", " & ");
Expand Down
5 changes: 5 additions & 0 deletions app/providers/MyUsernamePasswordAuthProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ public void sendInvitationByEmail(final MembershipInvitation invitation, String
mailer.sendMail(subject, body, invitation.getEmail());
}

public void sendZipContributionFile(String url, String email) {
final Body body = new Body("Your contribution files is ready, you can download here: "+ url);
mailer.sendMail("Contribution File", body, email);
}

private String getEmailName(final User user) {
return getEmailName(user.getEmail(), user.getName());
}
Expand Down
16 changes: 16 additions & 0 deletions app/utils/Packager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package utils;

import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand All @@ -24,6 +26,20 @@ public static void packZip(File output, List<File> sources, String format) throw
zipOut.close();
}

public static void packZip(File output, List<File> sources) throws IOException
{
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);

for (File source : sources)
{
zipFile(zipOut, "", source, "");
}
zipOut.flush();
zipOut.close();
}


private static String buildPath(String path, String file)
{
if (path == null || path.isEmpty())
Expand Down
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "2.4.6",
"org.jsoup" % "jsoup" % "1.10.2",
"com.typesafe.akka" %% "akka-actor" % "2.3.11",
"com.typesafe.akka" %% "akka-testkit" % "2.3.11" % "test"
"com.typesafe.akka" %% "akka-testkit" % "2.3.11" % "test",
"org.json" % "json" % "20171018",
"com.github.opendevl" % "json2flat" % "1.0.3",
"org.apache.poi" % "poi-ooxml" % "3.17",
"com.google.api-client" % "google-api-client" % "1.23.0"

)

libraryDependencies += evolutions
Expand Down
2 changes: 2 additions & 0 deletions conf/local.sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ logger {
application {
baseUrl="http://testplatform.appcivist.org/backend/api" # no longer works, but used for email invitations
uiUrl="http://testplatform.appcivist.org/#" # no longer works, but used for email invitations
contributionFiles="http://appcivist.littlemacondo.com/public/contributionsFiles/"
contributionFilesPath="/public/contributionsFiles/"

# Router
# ~~~~~
Expand Down
6 changes: 2 additions & 4 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ POST /api/space/:sid/ballot
POST /api/space/:sid/config controllers.Configs.createSpaceConfig(sid: Long)
POST /api/space/:sid/resource controllers.Spaces.addSpaceResources(sid: Long)
POST /api/space/:sid/contribution controllers.Contributions.createContributionInResourceSpaceWithId(sid: Long)
GET /api/space/:sid/export/contribution/:cid controllers.Contributions.exportContributionProposal(sid: Long, cid: Long, format?="", include?="")
GET /api/space/:sid/export/contribution controllers.Contributions.exportSpaceContributionProposal(sid: Long, format?="", include?="")
GET /api/space/:sid/insights/themes controllers.Spaces.exportSpaceThemeStats(sid: Long, type?="")

GET /api/space/:sid/ballot/:bid controllers.Spaces.findSpaceBallotById(sid: Long, bid: Long)
Expand All @@ -348,8 +346,8 @@ GET /api/space/:sid/config/:uuid
GET /api/space/:sid/config controllers.Configs.findSpaceConfigs(sid: Long)
PUT /api/space/:sid/config/:uuid controllers.Spaces.updateSpaceCampaignConfig(sid: Long, uuid: java.util.UUID)
PUT /api/space/:sid/config controllers.Configs.updateSpaceConfig(sid: Long)
GET /api/space/:sid/contribution/:cid controllers.Contributions.findResourceSpaceContributionById(sid: Long, cid: Long)
GET /api/space/:sid/contribution controllers.Contributions.findResourceSpaceContributions(sid: Long, type?="", by_text?="", groups: java.util.List[Integer] ?=null, themes: java.util.List[Integer] ?=null, all: String ?= null, by_author:Integer?=0, page:Integer?=0, pageSize:Integer?=16, sorting?="", random: String ?= null, status: String?="")
GET /api/space/:sid/contribution/:cid controllers.Contributions.findResourceSpaceContributionById(sid: Long, cid: Long, format?="JSON", includeExtendedText?="false", extendedTextFormat?="")
GET /api/space/:sid/contribution controllers.Contributions.findResourceSpaceContributions(sid: Long, type?="", by_text?="", groups: java.util.List[Integer] ?=null, themes: java.util.List[Integer] ?=null, all: String ?= null, by_author:Integer?= null, page:Integer?=0, pageSize:Integer?=null, sorting?="", random: String ?= null, status: String?="", format?="JSON", includeExtendedText?="false", extendedTextFormat?="", collectionFileFormat?="CSV", selectedContributions: java.util.List[String])
GET /api/space/:sid/resource/:rid controllers.Campaigns.listSpaceResourcesById(sid: Long, rid: Long)
GET /api/space/:sid/resource controllers.Campaigns.listSpaceResources(sid: Long)
GET /api/space/:sid/component/:cid controllers.Spaces.listSpaceComponentById(sid: Long, cid: Long)
Expand Down

0 comments on commit 49c41e2

Please sign in to comment.