Exemplo n.º 1
0
    def ready(self):
        from actstream.actions import action_handler
        action.connect(action_handler, dispatch_uid='actstream.models')
        action_class = self.get_model('action')

        if settings.USE_JSONFIELD:
            from actstream.jsonfield import DataField, register_app
            DataField(blank=True,
                      null=True).contribute_to_class(action_class, 'data')
            register_app(self)
Exemplo n.º 2
0
    def ready(self):
        from actstream.actions import action_handler
        action.connect(action_handler, dispatch_uid='actstream.models')
        action_class = self.get_model('action')

        if actstream_settings.USE_JSONFIELD:
            if not hasattr(action_class, 'data'):
                from actstream.jsonfield import DataField
                DataField(blank=True, null=True).contribute_to_class(
                    action_class, 'data'
                )

            # dynamically load django_jsonfield_backport to INSTALLED_APPS
            if django.VERSION < (3, 1) and 'django_jsonfield_backport' not in settings.INSTALLED_APPS:
                settings.INSTALLED_APPS += ('django_jsonfield_backport', )
                # reset loaded apps
                apps.app_configs = OrderedDict()
                # reset initialization status
                apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
                apps.clear_cache()
                # re-initialize all apps
                apps.populate(settings.INSTALLED_APPS)
Exemplo n.º 3
0
class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '__first__'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  primary_key=True,
                                  serialize=False,
                                  help_text='',
                                  auto_created=True)),
                ('actor_object_id',
                 models.CharField(max_length=255, db_index=True,
                                  help_text='')),
                ('verb',
                 models.CharField(max_length=255, db_index=True,
                                  help_text='')),
                ('description',
                 models.TextField(blank=True, null=True, help_text='')),
                ('target_object_id',
                 models.CharField(max_length=255,
                                  blank=True,
                                  null=True,
                                  db_index=True,
                                  help_text='')),
                ('action_object_object_id',
                 models.CharField(max_length=255,
                                  blank=True,
                                  null=True,
                                  db_index=True,
                                  help_text='')),
                ('timestamp',
                 models.DateTimeField(db_index=True,
                                      default=django.utils.timezone.now,
                                      help_text='')),
                ('public',
                 models.BooleanField(db_index=True, default=True,
                                     help_text='')),
                ('data', DataField(blank=True, null=True, help_text='')),
                ('action_object_content_type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   blank=True,
                                   null=True,
                                   help_text='',
                                   related_name='action_object',
                                   to='contenttypes.ContentType')),
                ('actor_content_type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   help_text='',
                                   related_name='actor',
                                   to='contenttypes.ContentType')),
                ('target_content_type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   blank=True,
                                   null=True,
                                   help_text='',
                                   related_name='target',
                                   to='contenttypes.ContentType')),
            ],
            options={
                'ordering': ('-timestamp', ),
            },
        ),
        migrations.RunSQL(
            'ALTER TABLE actstream_action DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;',
            reverse_sql=migrations.RunSQL.noop),
        migrations.RunSQL(
            'ALTER TABLE actstream_action CONVERT TO CHARACTER SET utf8;',
            reverse_sql=migrations.RunSQL.noop),
        migrations.CreateModel(
            name='Follow',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  primary_key=True,
                                  serialize=False,
                                  help_text='',
                                  auto_created=True)),
                ('object_id',
                 models.CharField(max_length=255, db_index=True,
                                  help_text='')),
                ('actor_only',
                 models.BooleanField(
                     verbose_name=
                     'Only follow actions where the object is the target.',
                     default=True,
                     help_text='')),
                ('started',
                 models.DateTimeField(db_index=True,
                                      default=django.utils.timezone.now,
                                      help_text='')),
                ('content_type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   help_text='',
                                   to='contenttypes.ContentType')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   help_text='',
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.RunSQL(
            'ALTER TABLE actstream_follow DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;',
            reverse_sql=migrations.RunSQL.noop),
        migrations.RunSQL(
            'ALTER TABLE actstream_follow CONVERT TO CHARACTER SET utf8;',
            reverse_sql=migrations.RunSQL.noop),
        migrations.AlterUniqueTogether(
            name='follow',
            unique_together=set([('user', 'content_type', 'object_id')]),
        ),
    ]