Search in sources :

Example 6 with ContributorLicenseAgreement

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

the class CclaController method claForm.

@RequestMapping("/sign/{claName}/ccla")
public String claForm(@AuthenticationPrincipal User user, SignCorporateClaForm signCorporateClaForm, Map<String, Object> model) throws Exception {
    String claName = signCorporateClaForm.getClaName();
    Integer pullRequestId = signCorporateClaForm.getPullRequestId();
    String repositoryId = signCorporateClaForm.getRepositoryId();
    CorporateSignatureInfo corporateResponse = claService.findCorporateSignatureInfoFor(claName, user);
    ContributorLicenseAgreement cla = corporateResponse.getContributorLicenseAgreement();
    CorporateSignature signed = corporateResponse.getCorporateSignature();
    List<String> currentUserGitHubOrganizations = corporateResponse.getGitHubOrganizations();
    if (cla == null) {
        throw new ResourceNotFoundException();
    }
    if (cla.getSupersedingCla() != null) {
        cla = cla.getSupersedingCla();
    }
    signCorporateClaForm.setSigned(signed != null);
    signCorporateClaForm.setName(user.getName());
    signCorporateClaForm.setClaId(cla.getId());
    signCorporateClaForm.setRepositoryId(repositoryId);
    signCorporateClaForm.setPullRequestId(pullRequestId);
    signCorporateClaForm.setGitHubOrganizations(currentUserGitHubOrganizations);
    model.put("cla", cla);
    return "cla/ccla/sign";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) CorporateSignature(io.pivotal.cla.data.CorporateSignature) CorporateSignatureInfo(io.pivotal.cla.service.CorporateSignatureInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ContributorLicenseAgreement

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

the class CclaController method view.

@GetMapping("/view/{claName}/ccla")
public String view(@PathVariable String claName, Map<String, Object> model) throws Exception {
    ContributorLicenseAgreement cla = clas.findByNameAndPrimaryTrue(claName);
    if (cla == null) {
        throw new ResourceNotFoundException();
    }
    if (cla.getSupersedingCla() != null) {
        cla = cla.getSupersedingCla();
    }
    model.put("cla", cla);
    return "cla/ccla/view";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with ContributorLicenseAgreement

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

the class IclaController method signCla.

@RequestMapping(value = "/sign/{claName}/icla", method = RequestMethod.POST)
public String signCla(@AuthenticationPrincipal User user, @Valid SignClaForm signClaForm, BindingResult result, Map<String, Object> model, RedirectAttributes redirect) throws Exception {
    String claName = signClaForm.getClaName();
    Integer pullRequestId = signClaForm.getPullRequestId();
    String repositoryId = signClaForm.getRepositoryId();
    ContributorLicenseAgreement cla = clas.findOne(signClaForm.getClaId());
    if (result.hasErrors()) {
        model.put("cla", cla);
        return "cla/icla/sign";
    }
    IndividualSignature signature = new IndividualSignature();
    signature.setCla(cla);
    signature.setName(signClaForm.getName());
    signature.setCountry(signClaForm.getCountry());
    signature.setEmail(signClaForm.getEmail());
    signature.setMailingAddress(signClaForm.getMailingAddress());
    signature.setDateOfSignature(new Date());
    signature.setTelephone(signClaForm.getTelephone());
    signature.setGitHubLogin(user.getGitHubLogin());
    individual.save(signature);
    // update github
    redirect.addAttribute("claName", claName);
    if (repositoryId == null || pullRequestId == null) {
        return "redirect:/sign/{claName}/icla";
    }
    ClaPullRequestStatusRequest updatePullRequest = signClaForm.createUpdatePullRequestStatus(user.getGitHubLogin());
    if (updatePullRequest != null) {
        updatePullRequest.getCommitStatus().setSuccess(true);
        claService.savePullRequestStatus(updatePullRequest);
    }
    redirect.addAttribute("repositoryId", repositoryId);
    redirect.addAttribute("pullRequestId", pullRequestId);
    return "redirect:/sign/{claName}/icla";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) ClaPullRequestStatusRequest(io.pivotal.cla.service.ClaPullRequestStatusRequest) Date(java.util.Date) IndividualSignature(io.pivotal.cla.data.IndividualSignature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ContributorLicenseAgreement

use of io.pivotal.cla.data.ContributorLicenseAgreement 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)

Example 10 with ContributorLicenseAgreement

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

the class CclaControllerTests method signFormSupersedingCla.

@Test
public void signFormSupersedingCla() {
    ContributorLicenseAgreement springCla = DataUtils.createSpringCla();
    springCla.setSupersedingCla(cla);
    when(mockClaRepository.findByNameAndPrimaryTrue(springCla.getName())).thenReturn(springCla);
    SignCclaPage signPage = SignCclaPage.go(getDriver(), springCla.getName());
    signPage.assertClaLink(springCla.getName());
    assertThat(signPage.getCorporate()).isEqualTo(cla.getCorporateContent().getHtml());
    assertThat(signPage.isSigned()).isFalse();
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Test(org.junit.Test)

Aggregations

ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)24 Test (org.junit.Test)14 AdminListClasPage (io.pivotal.cla.webdriver.pages.admin.AdminListClasPage)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 AdminEditClaPage (io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage)6 CorporateSignature (io.pivotal.cla.data.CorporateSignature)4 AdminCreateClaPage (io.pivotal.cla.webdriver.pages.admin.AdminCreateClaPage)4 IndividualSignature (io.pivotal.cla.data.IndividualSignature)3 MarkdownContent (io.pivotal.cla.data.MarkdownContent)2 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)2 SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)2 SignIclaPage (io.pivotal.cla.webdriver.pages.SignIclaPage)2 Date (java.util.Date)2 CorporateSignatureInfo (io.pivotal.cla.service.CorporateSignatureInfo)1 ClaForm (io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm)1 Before (org.junit.Before)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1