Search in sources :

Example 1 with MarkdownContent

use of io.pivotal.cla.data.MarkdownContent in project pivotal-cla by pivotalsoftware.

the class BaseWebDriverTests method setup.

@Before
public void setup() {
    driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc).useMockMvcForHosts("github.com").build();
    MarkdownContent corporate = new MarkdownContent();
    corporate.setMarkdown("# Corporate");
    corporate.setHtml("[h1]Corporate[/h1]");
    MarkdownContent individual = new MarkdownContent();
    individual.setMarkdown("# Individual");
    individual.setHtml("[h1]Individual[/h1]");
    cla = new ContributorLicenseAgreement();
    cla.setName("pivotal");
    cla.setCorporateContent(corporate);
    cla.setIndividualContent(individual);
    cla.setId(1L);
    individualSignature = new IndividualSignature();
    individualSignature.setCla(cla);
    individualSignature.setGitHubLogin("rwinch");
    individualSignature.setEmail("rob@gmail.com");
    individualSignature.setName("Rob Winch");
    individualSignature.setMailingAddress("123 Seasame Street");
    individualSignature.setTelephone("123.456.7890");
    corporateSignature = new CorporateSignature();
    corporateSignature.setCla(cla);
    corporateSignature.setGitHubLogin("rwinch");
    corporateSignature.setEmail("rob@gmail.com");
    corporateSignature.setName("Rob Winch");
    corporateSignature.setMailingAddress("123 Seasame Street");
    corporateSignature.setTelephone("123.456.7890");
    corporateSignature.setGitHubOrganization("organization");
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) MarkdownContent(io.pivotal.cla.data.MarkdownContent) CorporateSignature(io.pivotal.cla.data.CorporateSignature) IndividualSignature(io.pivotal.cla.data.IndividualSignature) Before(org.junit.Before)

Example 2 with MarkdownContent

use of io.pivotal.cla.data.MarkdownContent in project pivotal-cla by pivotalsoftware.

the class AdminCrudClaController method saveCla.

@RequestMapping(value = "/admin/cla", method = RequestMethod.POST)
public String saveCla(@AuthenticationPrincipal User user, @Valid ClaForm claForm, BindingResult result, Map<String, Object> model) throws Exception {
    boolean primary = claForm.isPrimary();
    if (primary) {
        ContributorLicenseAgreement existingPrimaryCla = claRepo.findByNameAndPrimaryTrue(claForm.getName());
        Long existingPrimaryClaId = existingPrimaryCla == null ? null : existingPrimaryCla.getId();
        if (existingPrimaryClaId != null && !existingPrimaryClaId.equals(claForm.getId())) {
            result.rejectValue("primary", "errors.primary.exists", "A primary CLA with this name already exists");
        }
    }
    if (result.hasErrors()) {
        Iterable<ContributorLicenseAgreement> clas = claRepo.findAll();
        model.put("licenses", clas);
        return "admin/cla/form";
    }
    ContributorLicenseAgreement supersedingCla = null;
    if (claForm.getSupersedingCla() != null) {
        supersedingCla = claRepo.findOne(claForm.getSupersedingCla());
    }
    String accessToken = user.getAccessToken();
    MarkdownContent individual = claForm.getIndividualContent();
    String individualHtml = gitHub.markdownToHtml(accessToken, individual.getMarkdown());
    individual.setHtml(individualHtml);
    MarkdownContent corporate = claForm.getCorporateContent();
    String corperateHtml = gitHub.markdownToHtml(accessToken, corporate.getMarkdown());
    corporate.setHtml(corperateHtml);
    boolean isCreateNew = claForm.getId() == null;
    ContributorLicenseAgreement cla = isCreateNew ? new ContributorLicenseAgreement() : claRepo.findOne(claForm.getId());
    cla.setCorporateContent(claForm.getCorporateContent());
    cla.setDescription(claForm.getDescription());
    cla.setIndividualContent(claForm.getIndividualContent());
    cla.setName(claForm.getName());
    cla.setPrimary(claForm.isPrimary());
    cla.setSupersedingCla(supersedingCla);
    claRepo.save(cla);
    return "redirect:/admin/cla/?success";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) MarkdownContent(io.pivotal.cla.data.MarkdownContent) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)2 MarkdownContent (io.pivotal.cla.data.MarkdownContent)2 CorporateSignature (io.pivotal.cla.data.CorporateSignature)1 IndividualSignature (io.pivotal.cla.data.IndividualSignature)1 Before (org.junit.Before)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1