Example #1
0
        content_types = [
            ContentType.objects.get_for_model(Page),
            ContentType.objects.get_for_model(PageComment),
            ContentType.objects.get_for_model(Status),
            ContentType.objects.get_for_model(Project),
        ]
        return activities.filter(target_content_type__in=content_types)

    @staticmethod
    def filter_learning_activities(activities):
        pages_ct = ContentType.objects.get_for_model(Page)
        comments_ct = ContentType.objects.get_for_model(PageComment)
        return activities.filter(
            target_content_type__in=[pages_ct, comments_ct])

register_filter('default', Project.filter_activities)
register_filter('learning', Project.filter_learning_activities)


class Participation(ModelBase):
    user = models.ForeignKey('users.UserProfile',
        related_name='participations')
    project = models.ForeignKey('projects.Project',
        related_name='participations')
    organizing = models.BooleanField(default=False)
    adopter = models.BooleanField(default=False)
    joined_on = models.DateTimeField(
        auto_now_add=True, default=datetime.datetime.now)
    left_on = models.DateTimeField(blank=True, null=True)
    # Notification Preferences.
    no_organizers_wall_updates = models.BooleanField(default=False)
Example #2
0
                'scope_pk': self.project.id,
            })
        callback_url = reverse('page_comment_callback', kwargs=kwargs)
    
        send_notifications_i18n(
            profiles, subject_template, body_template, context,
            callback_url, self.author.username,
            notification_category=u'course-announcement.project-{0}'.format(self.project.slug)
        )

    @staticmethod
    def filter_activities(activities):
        ct = ContentType.objects.get_for_model(Status)
        return activities.filter(target_content_type=ct)

register_filter('messages', Status.filter_activities)


###########
# Signals #
###########


def status_creation_handler(sender, **kwargs):
    status = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    if not created or not isinstance(status, Status):
        return

    # fire activity
Example #3
0
        content_types = [
            ContentType.objects.get_for_model(Page),
            ContentType.objects.get_for_model(PageComment),
            ContentType.objects.get_for_model(Status),
            ContentType.objects.get_for_model(Project),
        ]
        return activities.filter(target_content_type__in=content_types)

    @staticmethod
    def filter_learning_activities(activities):
        pages_ct = ContentType.objects.get_for_model(Page)
        comments_ct = ContentType.objects.get_for_model(PageComment)
        return activities.filter(
            target_content_type__in=[pages_ct, comments_ct])

register_filter('default', Project.filter_activities)
register_filter('learning', Project.filter_learning_activities)


class Participation(ModelBase):
    user = models.ForeignKey('users.UserProfile',
        related_name='participations')
    project = models.ForeignKey('projects.Project',
        related_name='participations')
    organizing = models.BooleanField(default=False)
    adopter = models.BooleanField(default=False)
    joined_on = models.DateTimeField(
        auto_now_add=True, default=datetime.datetime.now)
    left_on = models.DateTimeField(blank=True, null=True)
    # Notification Preferences.
    no_organizers_wall_updates = models.BooleanField(default=False)
Example #4
0
            profiles,
            subject_template,
            body_template,
            context,
            callback_url,
            self.author.username,
            notification_category=u'course-announcement.project-{0}'.format(
                self.project.slug))

    @staticmethod
    def filter_activities(activities):
        ct = ContentType.objects.get_for_model(Status)
        return activities.filter(target_content_type=ct)


register_filter('messages', Status.filter_activities)

###########
# Signals #
###########


def status_creation_handler(sender, **kwargs):
    status = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    if not created or not isinstance(status, Status):
        return

    # fire activity
    activity = Activity(
Example #5
0
        content_types = [
            ContentType.objects.get_for_model(Page),
            ContentType.objects.get_for_model(PageComment),
            ContentType.objects.get_for_model(Status),
            ContentType.objects.get_for_model(Project),
        ]
        return activities.filter(target_content_type__in=content_types)

    @staticmethod
    def filter_learning_activities(activities):
        pages_ct = ContentType.objects.get_for_model(Page)
        comments_ct = ContentType.objects.get_for_model(PageComment)
        return activities.filter(target_content_type__in=[pages_ct, comments_ct])


register_filter("default", Project.filter_activities)
register_filter("learning", Project.filter_learning_activities)


class Participation(ModelBase):
    user = models.ForeignKey("users.UserProfile", related_name="participations")
    project = models.ForeignKey("projects.Project", related_name="participations")
    organizing = models.BooleanField(default=False)
    adopter = models.BooleanField(default=False)
    joined_on = models.DateTimeField(auto_now_add=True, default=datetime.datetime.now)
    left_on = models.DateTimeField(blank=True, null=True)
    # Notification Preferences.
    no_organizers_wall_updates = models.BooleanField(default=False)
    no_organizers_content_updates = models.BooleanField(default=False)
    no_participants_wall_updates = models.BooleanField(default=False)
    no_participants_content_updates = models.BooleanField(default=False)
Example #6
0
        target = (self.target_user or self.target_project)
        return target.get_absolute_url()

    def save(self, *args, **kwargs):
        """Check that the source and the target are not the same user."""
        if (self.source == self.target_user):
            raise ValidationError(
                _('Cannot create self referencing relationship.'))
        super(Relationship, self).save(*args, **kwargs)

    @staticmethod
    def filter_activities(activities):
        ct = ContentType.objects.get_for_model(Relationship)
        return activities.filter(target_content_type=ct)

register_filter('people', Relationship.filter_activities)


###########
# Signals #
###########


def follow_handler(sender, **kwargs):
    rel = kwargs.get('instance', None)
    created = kwargs.get('created', False)
    if not created or not isinstance(rel, Relationship) or rel.deleted:
        return
    activity = Activity(actor=rel.source,
                        verb=verbs['follow'],
                        target_object=rel)
Example #7
0
        target = self.target_user or self.target_project
        return target.get_absolute_url()

    def save(self, *args, **kwargs):
        """Check that the source and the target are not the same user."""
        if self.source == self.target_user:
            raise ValidationError(_("Cannot create self referencing relationship."))
        super(Relationship, self).save(*args, **kwargs)

    @staticmethod
    def filter_activities(activities):
        ct = ContentType.objects.get_for_model(Relationship)
        return activities.filter(target_content_type=ct)


register_filter("people", Relationship.filter_activities)


###########
# Signals #
###########


def follow_handler(sender, **kwargs):
    rel = kwargs.get("instance", None)
    created = kwargs.get("created", False)
    if not created or not isinstance(rel, Relationship) or rel.deleted:
        return
    activity = Activity(actor=rel.source, verb=verbs["follow"], target_object=rel)
    recipients = []
    if rel.target_user:
Example #8
0
        return target.get_absolute_url()

    def save(self, *args, **kwargs):
        """Check that the source and the target are not the same user."""
        if (self.source == self.target_user):
            raise ValidationError(
                _('Cannot create self referencing relationship.'))
        super(Relationship, self).save(*args, **kwargs)

    @staticmethod
    def filter_activities(activities):
        ct = ContentType.objects.get_for_model(Relationship)
        return activities.filter(target_content_type=ct)


register_filter('people', Relationship.filter_activities)

###########
# Signals #
###########


def follow_handler(sender, **kwargs):
    rel = kwargs.get('instance', None)
    created = kwargs.get('created', False)
    if not created or not isinstance(rel, Relationship) or rel.deleted:
        return
    activity = Activity(actor=rel.source,
                        verb=verbs['follow'],
                        target_object=rel)
    recipients = []