Ejemplo n.º 1
0
 def extra_fields(self):
     self.fields['parent_id'] = forms.CharField(widget=widgets.HiddenInput(),
                                                initial=self.repo['id'],
                                                required=False)
     self.fields['clone_id'] = \
         forms.CharField(label="Clone ID",
                         widget=CloneWidget(repo_utils.get_branch_id(self.repo)),
                         help_text="The repository ID of the ultimate ancestor of this repository will be automatically appended")
     self.fields['clone_name'] = \
         forms.CharField(label="Clone Name",
                         widget=CloneWidget(repo_utils.get_branch_name(self.repo), separator=': '),
                         help_text="The name of the ultimate ancestor of this repository will be automatically appended")
Ejemplo n.º 2
0
def clone(request, repo_id=None):
    repo = repo_utils.get_repo(repo_id)
    form = RepoCloneForm(request.POST or None, repo=repo)
    if request.method == 'POST':
        if form.is_valid():
            groups = filter(lambda s: s != '',
                            form.cleaned_data['groups'] + \
                            re.split(r'\s*,\s*',
                                     form.cleaned_data['newgroups']))

            clone_id = "%s-%s" % (form.cleaned_data["clone_id"],
                                  repo_utils.get_branch_id(repo))
            clone_name = "%s: %s" % (form.cleaned_data["clone_name"],
                                     repo_utils.get_branch_name(repo))
            CloneRepo.delay(clone_id,
                            parent=repo,
                            name=clone_name,
                            groups=groups,
                            filters=form.cleaned_data['filters'],
                            user=request.user.username)
            return HttpResponseRedirect(reverse('sponge.views.repos.list'))
    return dict(repo=repo, form=form)