Exemple #1
0
 def branch_delete(self, branch_name):
     try:
         branch = self.branches.get(name=branch_name)
         branch.delete()
     except Branch.DoesNotExist:
         pass
     template = "project/activity-feed/branch-delete.html"
     context = {"project": self, "branch": branch_name}
     users = self.notifiable_users()
     notify_users(users, template, context)
Exemple #2
0
 def tag_delete(self, tag_name):
     try:
         tag = self.tags.get(name=tag_name)
         tag.delete()
     except Tag.DoesNotExist:
         pass
     template = "project/activity-feed/tag-delete.html"
     context = {"project": self, "tag": tag_name}
     users = self.notifiable_users()
     notify_users(users, template, context)
Exemple #3
0
    def delete(self, *args, **kwargs):
        # Make sure that the user knows about the key being deleted
        user = self.user
        template = 'settings/activity-feed/public-key-delete.html'
        context = {'user': user, 'public_key': self}
        notify_users(user, template, context)
        super(PublicKey, self).delete(*args, **kwargs)

        # Remove the key from the backend
        ssh_manager.delete(self)
Exemple #4
0
    def save(self, *args, **kwargs):
        super(PublicKey, self).save(*args, **kwargs)

        # Make sure that the user knows about the key being added
        user = self.user
        template = 'settings/activity-feed/public-key-new.html'
        context = {'user': user, 'public_key': self}
        notify_users(user, template, context)

        # Now use the registered SSH backend for installing the
        # public key for this user.
        ssh_manager.run(self)
Exemple #5
0
    def post_receive_action(self, klass, action, *args, **kwargs):
        refname = kwargs["refname"]
        old_rev, new_rev = kwargs["old_rev"], kwargs["new_rev"]

        if klass == "branch":
            self.post_receive_commit(action, old_rev, new_rev, refname)
        elif klass == "tag":
            self.post_receive_tag(action, old_rev, new_rev, refname)

        template = "project/activity-feed/{}-{}.html".format(klass, action)
        cmd = "{}_{}_signal".format(klass, action)
        users = self.notifiable_users()
        notify_users(users, template, kwargs)
        getattr(Project, cmd).send(sender=self, **kwargs)
Exemple #6
0
    def create_project(self):
        clone = self.fork.get_absolute_path() if self.fork else None
        project_path = self.get_absolute_path()
        self.git = Git.clone_or_create(path=project_path, clone=clone)

        # Create a new activity stream depending if the project is forked
        template = "project/activity-feed/created.html"
        context = {"user": self.owner, "project": self, "organization": self.organization}

        # We either dispatch to the organization or to the owner
        users = (self.owner,)
        if self.organization:
            users = (role.user for role in self.organization.roles)

        if self.fork:
            template = "project/activity-feed/forked.html"
            context["parent"] = self.fork
            users.append(self.fork.owner)
        notify_users(users, template, context)
Exemple #7
0
 def tag_add(self, tag_name):
     template = "project/activity-feed/tag-add.html"
     context = {"project": self, "tag": tag_name}
     users = self.notifiable_users()
     notify_users(users, template, context)
Exemple #8
0
 def branch_add(self, branch_name):
     template = "project/activity-feed/branch-add.html"
     context = {"project": self, "branch": branch_name}
     users = self.notifiable_users()
     notify_users(users, template, context)
Exemple #9
0
 def star(self, user):
     self.starred_by.add(user)
     template = "project/activity-feed/star.html"
     context = {"user": user, "project": self}
     notify_users(user, template, context)