~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/browser/branchmergeproposal.py

[r=cjwatson][no-qa] Add a rescan button to branch merge proposals for
 failed branch or repository scans

Show diffs side-by-side

added added

removed removed

Lines of Context:
807
807
            return False
808
808
        return latest_preview.job.status == JobStatus.FAILED
809
809
 
 
810
    @property
 
811
    def show_rescan_link(self):
 
812
        source_job = self.context.merge_source.getLatestScanJob()
 
813
        target_job = self.context.merge_target.getLatestScanJob()
 
814
        if source_job and source_job.job.status == JobStatus.FAILED:
 
815
            return True
 
816
        if target_job and target_job.job.status == JobStatus.FAILED:
 
817
            return True
 
818
        return False
 
819
 
 
820
 
 
821
class BranchMergeProposalRescanView(LaunchpadEditFormView):
 
822
    schema = Interface
 
823
 
 
824
    field_names = []
 
825
 
 
826
    @action('Rescan', name='rescan')
 
827
    def rescan(self, action, data):
 
828
        source_job = self.context.merge_source.getLatestScanJob()
 
829
        target_job = self.context.merge_target.getLatestScanJob()
 
830
        if source_job and source_job.job.status == JobStatus.FAILED:
 
831
            self.context.merge_source.rescan()
 
832
        if target_job and target_job.job.status == JobStatus.FAILED:
 
833
            self.context.merge_target.rescan()
 
834
        self.request.response.addNotification("Rescan scheduled")
 
835
        self.next_url = canonical_url(self.context)
 
836
 
810
837
 
811
838
@delegate_to(ICodeReviewVoteReference)
812
839
class DecoratedCodeReviewVoteReference: