use of ai.elimu.model.project.AppCollection in project webapp by elimu-ai.
the class AppCollectionCreateController method handleSubmit.
@RequestMapping(method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @Valid AppCollection appCollection, BindingResult result, Model model) {
logger.info("handleSubmit");
Project project = appCollection.getProject();
model.addAttribute("project", project);
// Disallow app collections with identical name
List<AppCollection> existingAppCollections = appCollectionDao.readAll(project);
for (AppCollection existingAppCollection : existingAppCollections) {
if (existingAppCollection.getName().equals(appCollection.getName())) {
result.rejectValue("name", "NonUnique");
break;
}
}
if (result.hasErrors()) {
model.addAttribute("appCollection", appCollection);
return "project/app-collection/create";
} else {
appCollectionDao.create(appCollection);
if (EnvironmentContextLoaderListener.env == Environment.PROD) {
// Notify project members in Slack
Contributor contributor = (Contributor) session.getAttribute("contributor");
String text = URLEncoder.encode(contributor.getFirstName() + " just added a new App Collection:\n" + "• Project: \"" + appCollection.getProject().getName() + "\"\n" + "• App Collection: \"" + appCollection.getName() + "\"\n" + "See ") + "http://elimu.ai/project/" + appCollection.getProject().getId();
SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
}
return "redirect:/project/" + appCollection.getProject().getId();
}
}
use of ai.elimu.model.project.AppCollection in project webapp by elimu-ai.
the class AppCollectionCreateController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, Model model, HttpSession session) {
logger.info("handleRequest");
Project project = projectDao.read(projectId);
model.addAttribute("project", project);
AppCollection appCollection = new AppCollection();
appCollection.setProject(project);
model.addAttribute("appCollection", appCollection);
return "project/app-collection/create";
}
use of ai.elimu.model.project.AppCollection in project webapp by elimu-ai.
the class AppCollectionEditController method handleRequest.
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long id, Model model, HttpSession session) {
logger.info("handleRequest");
// Needed by breadcrumbs
Project project = projectDao.read(projectId);
model.addAttribute("project", project);
AppCollection appCollection = appCollectionDao.read(id);
model.addAttribute("appCollection", appCollection);
List<License> licenses = licenseDao.readAll(appCollection);
model.addAttribute("licenses", licenses);
return "project/app-collection/edit";
}
use of ai.elimu.model.project.AppCollection in project webapp by elimu-ai.
the class LicenseCreateController method sendLicenseInEmail.
/**
* Sends an e-mail with the License details necessary to be able to use the Appstore application for downloading
* an AppCollection.
*
* @param license The License to send in the e-mail
* @param contributor The project manager who generated the License
*/
private void sendLicenseInEmail(License license, Contributor projectManager) {
logger.info("sendLicenseInEmail");
AppCollection appCollection = license.getAppCollection();
String to = license.getLicenseEmail();
String from = "elimu.ai <info@elimu.ai>";
String subject = "License number - " + appCollection.getName();
String title = "Your license is ready!";
String firstName = license.getFirstName();
String htmlText = "<p>Hi, " + firstName + "</p>";
htmlText += "<p>We have prepared a license number for you so that you can download and use our software.</p>";
htmlText += "<h2>License Details</h2>";
htmlText += "<p>";
htmlText += "E-mail: " + license.getLicenseEmail() + "<br />";
htmlText += "Number: " + license.getLicenseNumber() + "<br />";
htmlText += "</p>";
htmlText += "<p>";
htmlText += "First name: " + license.getFirstName() + "<br />";
htmlText += "Last name: " + license.getLastName() + "<br />";
if (!StringUtils.isBlank(license.getOrganization())) {
htmlText += "Organization: " + license.getOrganization() + "<br />";
}
htmlText += "</p>";
htmlText += "<h2>App Collection - " + appCollection.getName() + "</h2>";
htmlText += "<p>This license is valid for the app collection \"" + appCollection.getName() + "\", which " + "contains the following app categories:</p>";
htmlText += "<ul>";
for (AppCategory appCategory : appCollection.getAppCategories()) {
htmlText += "<li>" + appCategory.getName() + "</li>";
}
htmlText += "</ul>";
htmlText += "<h2>How to Start?</h2>";
htmlText += "<ol>";
htmlText += "<li>Install our Appstore application</li>";
htmlText += "<li>Open Appstore and type your e-mail + license number</li>";
htmlText += "<li>Download apps</li>";
htmlText += "</ol>";
htmlText += "<h2>Download Appstore</h2>";
htmlText += "<p>At https://github.com/elimu-ai/appstore/releases you can download the latest version of our Appstore " + "application which helps you download the entire collection of educational Android apps.</p>";
htmlText += "<p>Make sure you download the file named \"ai.elimu.appstore<b>_custom</b>-<version>.apk\". " + "Start by clicking the button below:</p>";
Mailer.sendHtmlWithButton(to, projectManager.getEmail(), from, subject, title, htmlText, "Download APK", "https://github.com/elimu-ai/appstore/releases");
}
use of ai.elimu.model.project.AppCollection in project webapp by elimu-ai.
the class LicenseCreateController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long appCollectionId, Model model, HttpSession session) {
logger.info("handleRequest");
// Needed by breadcrumbs
Project project = projectDao.read(projectId);
model.addAttribute("project", project);
AppCollection appCollection = appCollectionDao.read(appCollectionId);
model.addAttribute("appCollection", appCollection);
License license = new License();
license.setLicenseNumber(LicenseGenerator.generateLicenseNumber());
license.setAppCollection(appCollection);
model.addAttribute("license", license);
return "project/license/create";
}
Aggregations