play.i18n.Messages Java Examples

The following examples show how to use play.i18n.Messages. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgrammingProblemSubmissionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listSubmissions(long problemId, long pageIndex, String orderBy, String orderDir) throws ProblemNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!ProgrammingProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        return notFound();
    }

    Page<ProgrammingSubmission> pageOfProgrammingSubmissions = programmingSubmissionService.getPageOfProgrammingSubmissions(pageIndex, PAGE_SIZE, orderBy, orderDir, null, problem.getJid(), null);
    Map<String, String> gradingLanguageToNameMap = GradingLanguageRegistry.getInstance().getNamesMap();

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listSubmissionsView.render(pageOfProgrammingSubmissions, gradingLanguageToNameMap, problemId, pageIndex, orderBy, orderDir));
    template.markBreadcrumbLocation(Messages.get("problem.programming.submission.list"), routes.ProgrammingProblemSubmissionController.viewSubmissions(problemId));
    template.setPageTitle("Problem - Submissions");

    return renderTemplate(template, problemService, problem);
}
 
Example #2
Source File: CRUD.java    From restcommander with Apache License 2.0 6 votes vote down vote up
public static void save(String id) throws Exception {
    ObjectType type = ObjectType.get(getControllerClass());
    notFoundIfNull(type);
    Model object = type.findById(id);
    notFoundIfNull(object);
    Binder.bindBean(params.getRootParamNode(), "object", object);
    validation.valid(object);
    if (validation.hasErrors()) {
        renderArgs.put("error", play.i18n.Messages.get("crud.hasErrors"));
        try {
            render(request.controller.replace(".", "/") + "/show.html", type, object);
        } catch (TemplateNotFoundException e) {
            render("CRUD/show.html", type, object);
        }
    }
    object._save();
    flash.success(play.i18n.Messages.get("crud.saved", type.modelName));
    if (params.get("_save") != null) {
        redirect(request.controller + ".list");
    }
    redirect(request.controller + ".show", object._key());
}
 
Example #3
Source File: LessonStatementController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
protected Result renderTemplate(HtmlTemplate template, LessonService lessonService, Lesson lesson) {
    template.addSecondaryTab(Messages.get("commons.view"), routes.LessonStatementController.viewStatement(lesson.getId()));

    if (LessonControllerUtils.isAllowedToUpdateStatement(lessonService, lesson)) {
        template.addSecondaryTab(Messages.get("commons.update"), routes.LessonStatementController.editStatement(lesson.getId()));
    }

    template.addSecondaryTab(Messages.get("lesson.statement.media"), routes.LessonStatementController.listStatementMediaFiles(lesson.getId()));

    if (LessonControllerUtils.isAllowedToManageStatementLanguages(lessonService, lesson)) {
        template.addSecondaryTab(Messages.get("lesson.statement.language"), routes.LessonStatementController.listStatementLanguages(lesson.getId()));
    }

    template.markBreadcrumbLocation(Messages.get("lesson.statement"), org.iatoki.judgels.sandalphon.lesson.routes.LessonController.jumpToStatement(lesson.getId()));

    return super.renderTemplate(template, lessonService, lesson);
}
 
Example #4
Source File: Account.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
@Restrict(@Group(LocalAuthController.USER_ROLE))
public static Result doChangePassword() {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final Form<Account.PasswordChange> filledForm = PASSWORD_CHANGE_FORM
			.bindFromRequest();
	if (filledForm.hasErrors()) {
		// User did not select whether to link or not link
		return badRequest(password_change.render(filledForm));
	} else {
		final User user = LocalAuthController.getLocalUser(session());
		final String newPassword = filledForm.get().password;
		user.changePassword(new GSNUsernamePasswordAuthUser(newPassword),
				true);
		flash(LocalAuthController.FLASH_MESSAGE_KEY,
				Messages.get("playauthenticate.change_password.success"));
		return redirect(routes.LocalAuthController.profile());
	}
}
 
Example #5
Source File: LocalAuthController.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
public static Result doAdduser() {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final Form<GSNSignup> filledForm = GSNUsernamePasswordAuthProvider.SIGNUP_FORM
			.bindFromRequest();
	if (filledForm.hasErrors()) {
		return badRequest(adduser.render(filledForm));
	} else {
		GSNUsernamePasswordAuthUser guser = new GSNUsernamePasswordAuthUser(filledForm.get());
		final User u = User.findByUsernamePasswordIdentity(guser);
		if (u != null) {
			flash(LocalAuthController.FLASH_ERROR_KEY,
					Messages.get("playauthenticate.user.exists.message"));
			return badRequest(adduser.render(filledForm));
		}
		// The user either does not exist or is inactive - create a new one
		// manually created users are directly validated
		@SuppressWarnings("unused")
		final User newUser = User.create(guser);
		newUser.emailValidated = true;
		newUser.save();
		return ok(adduser.render(GSNUsernamePasswordAuthProvider.SIGNUP_FORM));
	}
}
 
Example #6
Source File: LessonVersionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result editVersionLocalChanges(long lessonId) throws LessonNotFoundException {
    Lesson lesson = lessonService.findLessonById(lessonId);

    if (!LessonControllerUtils.isPartnerOrAbove(lessonService, lesson)) {
        return notFound();
    }

    lessonService.fetchUserClone(IdentityUtils.getUserJid(), lesson.getJid());

    if (!lessonService.updateUserClone(IdentityUtils.getUserJid(), lesson.getJid())) {
        flash("localChangesError", Messages.get("lesson.version.local.cantMerge"));
    }

    return redirect(routes.LessonVersionController.viewVersionLocalChanges(lesson.getId()));
}
 
Example #7
Source File: Account.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
@Restrict(@Group(LocalAuthController.USER_ROLE))
public static Result verifyEmail() {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final User user = LocalAuthController.getLocalUser(session());
	if (user.emailValidated) {
		// E-Mail has been validated already
		flash(LocalAuthController.FLASH_MESSAGE_KEY,
				Messages.get("playauthenticate.verify_email.error.already_validated"));
	} else if (user.email != null && !user.email.trim().isEmpty()) {
		flash(LocalAuthController.FLASH_MESSAGE_KEY, Messages.get(
				"playauthenticate.verify_email.message.instructions_sent",
				user.email));
		GSNUsernamePasswordAuthProvider.getProvider()
				.sendVerifyEmailMailingAfterSignup(user, ctx());
	} else {
		flash(LocalAuthController.FLASH_MESSAGE_KEY, Messages.get(
				"playauthenticate.verify_email.error.set_email_first",
				user.email));
	}
	return redirect(routes.LocalAuthController.profile());
}
 
Example #8
Source File: LessonVersionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listVersionHistory(long lessonId) throws LessonNotFoundException {
    Lesson lesson = lessonService.findLessonById(lessonId);

    if (!LessonControllerUtils.isAllowedToViewVersionHistory(lessonService, lesson)) {
        return notFound();
    }

    List<GitCommit> versions = lessonService.getVersions(IdentityUtils.getUserJid(), lesson.getJid());
    boolean isClean = !lessonService.userCloneExists(IdentityUtils.getUserJid(), lesson.getJid());
    boolean isAllowedToRestoreVersionHistory = isClean && LessonControllerUtils.isAllowedToRestoreVersionHistory(lessonService, lesson);

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listVersionsView.render(versions, lesson.getId(), isAllowedToRestoreVersionHistory));
    template.markBreadcrumbLocation(Messages.get("lesson.version.history"), routes.LessonVersionController.listVersionHistory(lesson.getId()));
    template.setPageTitle("Lesson - Versions - History");

    return renderTemplate(template, lessonService, lesson);
}
 
Example #9
Source File: LessonPartnerController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listPartners(long lessonId, long pageIndex, String orderBy, String orderDir) throws LessonNotFoundException {
    Lesson lesson = lessonService.findLessonById(lessonId);

    if (!LessonControllerUtils.isAuthorOrAbove(lesson)) {
        return notFound();
    }

    Page<LessonPartner> pageOfLessonPartners = lessonService.getPageOfLessonPartners(lesson.getJid(), pageIndex, PAGE_SIZE, orderBy, orderDir);

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listPartnersView.render(lesson.getId(), pageOfLessonPartners, orderBy, orderDir));
    template.setSecondaryTitle(Messages.get("lesson.partner.list"));
    template.addSecondaryButton(Messages.get("lesson.partner.add"), routes.LessonPartnerController.addPartner(lesson.getId()));
    template.markBreadcrumbLocation(Messages.get("lesson.partner.list"), routes.LessonPartnerController.viewPartners(lesson.getId()));
    template.setPageTitle("Lesson - Partners");

    return renderTemplate(template, lessonService, lesson);
}
 
Example #10
Source File: GroovyTemplate.java    From restcommander with Apache License 2.0 6 votes vote down vote up
public String __getMessage(Object[] val) {
    if (val==null) {
        throw new NullPointerException("You are trying to resolve a message with an expression " +
                "that is resolved to null - " +
                "have you forgotten quotes around the message-key?");
    }
    if (val.length == 1) {
        return Messages.get(val[0]);
    } else {
        // extract args from val
        Object[] args = new Object[val.length-1];
        for( int i=1;i<val.length;i++) {
            args[i-1] = val[i];
        }
        return Messages.get(val[0], args);
    }
}
 
Example #11
Source File: LessonController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional
@RequireCSRFCheck
public Result postEditLesson(long lessonId) throws LessonNotFoundException {
    Lesson lesson = lessonService.findLessonById(lessonId);

    if (!LessonControllerUtils.isAllowedToUpdateLesson(lessonService, lesson)) {
        return notFound();
    }

    Form<LessonEditForm> lessonEditForm = Form.form(LessonEditForm.class).bindFromRequest();

    if (formHasErrors(lessonEditForm)) {
        return showEditLesson(lessonEditForm, lesson);
    }

    if (!lesson.getSlug().equals(lessonEditForm.get().slug) && lessonService.lessonExistsBySlug(lessonEditForm.get().slug)) {
        lessonEditForm.reject("slug", Messages.get("error.lesson.slugExists"));
    }

    LessonEditForm lessonEditData = lessonEditForm.get();
    lessonService.updateLesson(lesson.getJid(), lessonEditData.slug, lessonEditData.additionalNote, IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());

    return redirect(routes.LessonController.viewLesson(lesson.getId()));
}
 
Example #12
Source File: Signup.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
public static Result verify(final String token) {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final TokenAction ta = tokenIsValid(token, Type.EMAIL_VERIFICATION);
	if (ta == null) {
		return badRequest(no_token_or_invalid.render());
	}
	final String email = ta.targetUser.email;
	User.verify(ta.targetUser);
	flash(LocalAuthController.FLASH_MESSAGE_KEY,
			Messages.get("playauthenticate.verify_email.success", email));
	if (LocalAuthController.getLocalUser(session()) != null) {
		return redirect(routes.LocalAuthController.index());
	} else {
		return redirect(routes.LocalAuthController.login());
	}
}
 
Example #13
Source File: ProblemController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional
@RequireCSRFCheck
public Result postCreateProblem() {
    Form<ProblemCreateForm> problemCreateForm = Form.form(ProblemCreateForm.class).bindFromRequest();

    if (formHasErrors(problemCreateForm)) {
        return showCreateProblem(problemCreateForm);
    }

    if (problemService.problemExistsBySlug(problemCreateForm.get().slug)) {
        problemCreateForm.reject("slug", Messages.get("error.problem.slugExists"));
    }

    ProblemCreateForm problemCreateData = problemCreateForm.get();
    ProblemControllerUtils.setJustCreatedProblem(problemCreateData.slug, problemCreateData.additionalNote, problemCreateData.initLanguageCode);

    if (problemCreateData.type.equals(ProblemType.PROGRAMMING.name())) {
        return redirect(org.iatoki.judgels.sandalphon.problem.programming.routes.ProgrammingProblemController.createProgrammingProblem());
    } else if (problemCreateData.type.equals(ProblemType.BUNDLE.name())) {
        return redirect(org.iatoki.judgels.sandalphon.problem.bundle.routes.BundleProblemController.createBundleProblem());
    }

    return internalServerError();
}
 
Example #14
Source File: BundleProblemControllerUtils.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
public static void appendTabs(HtmlTemplate template, ProblemService problemService, Problem problem) {
    template.addMainTab(Messages.get("problem.statement"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToStatement(problem.getId()));

    if (BundleProblemControllerUtils.isAllowedToManageItems(problemService, problem)) {
        template.addMainTab(Messages.get("problem.bundle.item"), org.iatoki.judgels.sandalphon.problem.bundle.routes.BundleProblemController.jumpToItems(problem.getId()));
    }

    if (BundleProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        template.addMainTab(Messages.get("problem.bundle.submission"), org.iatoki.judgels.sandalphon.problem.bundle.routes.BundleProblemController.jumpToSubmissions(problem.getId()));
    }

    if (ProblemControllerUtils.isAuthorOrAbove(problem)) {
        template.addMainTab(Messages.get("problem.partner"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToPartners(problem.getId()));
    }

    template.addMainTab(Messages.get("problem.version"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToVersions(problem.getId()));
}
 
Example #15
Source File: ProgrammingProblemSubmissionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result viewSubmission(long problemId, long submissionId) throws ProblemNotFoundException, ProgrammingSubmissionNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!ProgrammingProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        return notFound();
    }

    ProgrammingSubmission programmingSubmission = programmingSubmissionService.findProgrammingSubmissionById(submissionId);

    String engine;
    try {
        engine = programmingProblemService.getGradingEngine(IdentityUtils.getUserJid(), problem.getJid());
    } catch (IOException e) {
        engine = GradingEngineRegistry.getInstance().getDefault();
    }
    SubmissionSource submissionSource = ProgrammingSubmissionUtils.createSubmissionSourceFromPastSubmission(programmingSubmissionFileSystemProvider, null, programmingSubmission.getJid());

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(GradingEngineAdapterRegistry.getInstance().getByGradingEngineName(engine).renderViewSubmission(programmingSubmission, submissionSource, JidCacheServiceImpl.getInstance().getDisplayName(programmingSubmission.getAuthorJid()), null, problem.getSlug(), GradingLanguageRegistry.getInstance().get(programmingSubmission.getGradingLanguage()).getName(), null));

    template.markBreadcrumbLocation(Messages.get("problem.programming.submission.view"), routes.ProgrammingProblemSubmissionController.viewSubmission(problemId, submissionId));
    template.setPageTitle("Problem - View Submission");

    return renderTemplate(template, problemService, problem);
}
 
Example #16
Source File: ProblemStatementController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listStatementLanguages(long problemId) throws ProblemNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!ProblemControllerUtils.isAllowedToManageStatementLanguages(problemService, problem)) {
        return notFound();
    }

    Map<String, StatementLanguageStatus> availableLanguages;
    String defaultLanguage;
    try {
        availableLanguages = problemService.getAvailableLanguages(IdentityUtils.getUserJid(), problem.getJid());
        defaultLanguage = problemService.getDefaultLanguage(IdentityUtils.getUserJid(), problem.getJid());
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listStatementLanguagesView.render(availableLanguages, defaultLanguage, problem.getId()));
    template.markBreadcrumbLocation(Messages.get("problem.statement.language.list"), routes.ProblemStatementController.listStatementLanguages(problem.getId()));
    template.setPageTitle("Problem - Statement Languages");

    return renderStatementTemplate(template, problemService, problem);
}
 
Example #17
Source File: Account.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
@Restrict(@Group(LocalAuthController.USER_ROLE))
public static Result doEditProfile() {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final Form<Account.EditProfile> filledForm = EDIT_PROFILE_FORM
			.bindFromRequest();
	if (filledForm.hasErrors()) {
		// User did not select whether to link or not link
		return badRequest(edit_profile.render(filledForm));
	} else {
		final User user = LocalAuthController.getLocalUser(session());
		user.firstName = filledForm.get().firstname;
		user.lastName = filledForm.get().lastname;
		user.update();
		flash(LocalAuthController.FLASH_MESSAGE_KEY,
				Messages.get("playauthenticate.edit_profile.success"));
		return redirect(routes.LocalAuthController.profile());
	}
}
 
Example #18
Source File: AbstractProblemController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
protected Result renderStatementTemplate(HtmlTemplate template, ProblemService problemService, Problem problem) {
    template.markBreadcrumbLocation(Messages.get("problem.statement"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToStatement(problem.getId()));

    template.addSecondaryTab(Messages.get("commons.view"), org.iatoki.judgels.sandalphon.problem.base.statement.routes.ProblemStatementController.viewStatement(problem.getId()));
    if (ProblemControllerUtils.isAllowedToUpdateStatement(problemService, problem)) {
        template.addSecondaryTab(Messages.get("commons.update"), org.iatoki.judgels.sandalphon.problem.base.statement.routes.ProblemStatementController.editStatement(problem.getId()));
    }

    template.addSecondaryTab(Messages.get("problem.statement.media"), org.iatoki.judgels.sandalphon.problem.base.statement.routes.ProblemStatementController.listStatementMediaFiles(problem.getId()));

    if (ProblemControllerUtils.isAllowedToManageStatementLanguages(problemService, problem)) {
        template.addSecondaryTab(Messages.get("problem.statement.language"), org.iatoki.judgels.sandalphon.problem.base.statement.routes.ProblemStatementController.listStatementLanguages(problem.getId()));
    }

    return this.renderTemplate(template, problemService, problem);
}
 
Example #19
Source File: ProblemVersionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listVersionHistory(long problemId) throws ProblemNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!ProblemControllerUtils.isAllowedToViewVersionHistory(problemService, problem)) {
        return notFound();
    }

    List<GitCommit> versions = problemService.getVersions(IdentityUtils.getUserJid(), problem.getJid());
    boolean isClean = !problemService.userCloneExists(IdentityUtils.getUserJid(), problem.getJid());
    boolean isAllowedToRestoreVersionHistory = isClean && ProblemControllerUtils.isAllowedToRestoreVersionHistory(problemService, problem);

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listVersionsView.render(versions, problem.getId(), isAllowedToRestoreVersionHistory));
    template.markBreadcrumbLocation(Messages.get("problem.version.history"), routes.ProblemVersionController.listVersionHistory(problem.getId()));
    template.setPageTitle("Problem - Versions - History");

    return renderTemplate(template, problemService, problem);
}
 
Example #20
Source File: ProblemPartnerController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listPartners(long problemId, long pageIndex, String orderBy, String orderDir) throws ProblemNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!ProblemControllerUtils.isAuthorOrAbove(problem)) {
        return notFound();
    }

    Page<ProblemPartner> pageOfProblemPartners = problemService.getPageOfProblemPartners(problem.getJid(), pageIndex, PAGE_SIZE, orderBy, orderDir);

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listPartnersView.render(problem.getId(), pageOfProblemPartners, orderBy, orderDir));
    template.setSecondaryTitle(Messages.get("problem.partner.list"));
    template.addSecondaryButton(Messages.get("problem.partner.add"), routes.ProblemPartnerController.addPartner(problem.getId()));
    template.setPageTitle("Problem - Partners");

    return renderPartnerTemplate(template, problemService, problem);
}
 
Example #21
Source File: ProgrammingProblemControllerUtils.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
public static  void appendTabs(HtmlTemplate template, ProblemService problemService, Problem problem) {
    template.addMainTab(Messages.get("problem.statement"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToStatement(problem.getId()));

    if (ProgrammingProblemControllerUtils.isAllowedToManageGrading(problemService, problem)) {
        template.addMainTab(Messages.get("problem.programming.grading"), org.iatoki.judgels.sandalphon.problem.programming.routes.ProgrammingProblemController.jumpToGrading(problem.getId()));
    }

    if (ProgrammingProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        template.addMainTab(Messages.get("problem.programming.submission"), org.iatoki.judgels.sandalphon.problem.programming.routes.ProgrammingProblemController.jumpToSubmissions(problem.getId()));
    }

    if (ProblemControllerUtils.isAuthorOrAbove(problem)) {
        template.addMainTab(Messages.get("problem.partner"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToPartners(problem.getId()));
    }

    template.addMainTab(Messages.get("problem.version"), org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.jumpToVersions(problem.getId()));
}
 
Example #22
Source File: BundleProblemSubmissionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result listSubmissions(long problemId, long pageIndex, String orderBy, String orderDir) throws ProblemNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!BundleProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        return notFound();
    }

    Page<BundleSubmission> pageOfBundleSubmissions = bundleSubmissionService.getPageOfBundleSubmissions(pageIndex, PAGE_SIZE, orderBy, orderDir, null, problem.getJid(), null);

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listSubmissionsView.render(pageOfBundleSubmissions, problemId, pageIndex, orderBy, orderDir));
    template.markBreadcrumbLocation(Messages.get("problem.bundle.submission.list"), org.iatoki.judgels.sandalphon.problem.bundle.submission.routes.BundleProblemSubmissionController.viewSubmissions(problemId));
    template.setPageTitle("Problem - Submissions");

    return renderTemplate(template, problemService, problem);
}
 
Example #23
Source File: BundleProblemSubmissionController.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Transactional(readOnly = true)
public Result viewSubmission(long problemId, long submissionId) throws ProblemNotFoundException, BundleSubmissionNotFoundException {
    Problem problem = problemService.findProblemById(problemId);

    if (!BundleProblemControllerUtils.isAllowedToSubmit(problemService, problem)) {
        return notFound();
    }

    BundleSubmission bundleSubmission = bundleSubmissionService.findBundleSubmissionById(submissionId);
    BundleAnswer bundleAnswer;
    try {
        bundleAnswer = bundleSubmissionService.createBundleAnswerFromPastSubmission(bundleSubmissionFileSystemProvider, null, bundleSubmission.getJid());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(bundleSubmissionView.render(bundleSubmission, BundleSubmissionUtils.parseGradingResult(bundleSubmission), bundleAnswer, JidCacheServiceImpl.getInstance().getDisplayName(bundleSubmission.getAuthorJid()), null, problem.getSlug(), null));

    template.markBreadcrumbLocation(Messages.get("problem.programming.submission.view"), org.iatoki.judgels.sandalphon.problem.programming.submission.routes.ProgrammingProblemSubmissionController.viewSubmission(problemId, submissionId));
    template.setPageTitle("Problem - View Submission");

    return renderTemplate(template, problemService, problem);
}
 
Example #24
Source File: Account.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
@SubjectPresent
public static Result doLink() {
	com.feth.play.module.pa.controllers.Authenticate.noCache(response());
	final AuthUser u = PlayAuthenticate.getLinkUser(session());
	if (u == null) {
		// account to link could not be found, silently redirect to login
		return redirect(routes.LocalAuthController.index());
	}

	final Form<Accept> filledForm = ACCEPT_FORM.bindFromRequest();
	if (filledForm.hasErrors()) {
		// User did not select whether to link or not link
		return badRequest(ask_link.render(filledForm, u));
	} else {
		// User made a choice :)
		final boolean link = filledForm.get().accept;
		if (link) {
			flash(LocalAuthController.FLASH_MESSAGE_KEY,
					Messages.get("playauthenticate.accounts.link.success"));
		}
		return PlayAuthenticate.link(ctx(), link);
	}
}
 
Example #25
Source File: ProgrammingProblemGradingController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showEditLanguageRestriction(Form<LanguageRestrictionEditForm> languageRestrictionEditForm, Problem problem) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(editLanguageRestrictionView.render(languageRestrictionEditForm, problem));
    template.markBreadcrumbLocation(Messages.get("problem.programming.grading.languageRestriction.update"), routes.ProgrammingProblemGradingController.editLanguageRestriction(problem.getId()));
    template.setPageTitle("Problem - Update Language Restriction");

    return renderTemplate(template, problemService, problem);
}
 
Example #26
Source File: ProgrammingProblemGradingController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
protected Result renderTemplate(HtmlTemplate template, ProblemService problemService, Problem problem) {
    template.addSecondaryTab(Messages.get("problem.programming.grading.engine"), routes.ProgrammingProblemGradingController.editGradingEngine(problem.getId()));
    template.addSecondaryTab(Messages.get("problem.programming.grading.config"), routes.ProgrammingProblemGradingController.editGradingConfig(problem.getId()));
    template.addSecondaryTab(Messages.get("problem.programming.grading.testData"), routes.ProgrammingProblemGradingController.listGradingTestDataFiles(problem.getId()));
    template.addSecondaryTab(Messages.get("problem.programming.grading.helper"), routes.ProgrammingProblemGradingController.listGradingHelperFiles(problem.getId()));
    template.addSecondaryTab(Messages.get("problem.programming.grading.languageRestriction"), routes.ProgrammingProblemGradingController.editLanguageRestriction(problem.getId()));

    template.markBreadcrumbLocation(Messages.get("problem.programming.grading"), org.iatoki.judgels.sandalphon.problem.programming.routes.ProgrammingProblemController.jumpToGrading(problem.getId()));

    return super.renderTemplate(template, problemService, problem);
}
 
Example #27
Source File: ProgrammingProblemGradingController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showListGradingHelperFiles(Form<UploadFileForm> uploadFileForm, Problem problem, List<FileInfo> helperFiles) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listGradingHelperFilesView.render(uploadFileForm, problem.getId(), helperFiles));
    template.markBreadcrumbLocation(Messages.get("problem.programming.grading.helper.list"), routes.ProgrammingProblemGradingController.listGradingHelperFiles(problem.getId()));
    template.setPageTitle("Problem - List Grading Helper Files");

    return renderTemplate(template, problemService, problem);
}
 
Example #28
Source File: ProgrammingProblemGradingController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showListGradingTestDataFiles(Form<UploadFileForm> uploadFileForm, Problem problem, List<FileInfo> testDataFiles) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(listGradingTestDataFilesView.render(uploadFileForm, problem.getId(), testDataFiles));
    template.markBreadcrumbLocation(Messages.get("problem.programming.grading.testData.list"), routes.ProgrammingProblemGradingController.listGradingTestDataFiles(problem.getId()));
    template.setPageTitle("Problem - List Grading Test Data Files");

    return renderTemplate(template, problemService, problem);
}
 
Example #29
Source File: ProgrammingProblemGradingController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showEditGradingEngine(Form<GradingEngineEditForm> gradingEngineEditForm, Problem problem) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(editGradingEngineView.render(gradingEngineEditForm, problem));
    template.markBreadcrumbLocation(Messages.get("problem.programming.grading.engine.update"), routes.ProgrammingProblemGradingController.editGradingEngine(problem.getId()));
    template.setPageTitle("Problem - Update Grading Engine");

    return renderTemplate(template, problemService, problem);
}
 
Example #30
Source File: Account.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public String validate() {
	if (password == null || !password.equals(repeatPassword)) {
		return Messages
				.get("playauthenticate.change_password.error.passwords_not_same");
	}
	return null;
}