Exemple #1
0
    # location
    constituency = models.ForeignKey(
        'core.Place',
        limit_choices_to={
            'kind__slug': 'constituency',
        },
        blank=True,
        null=True,
    )

    objects = UserProfileManager()


# make sure that profiles are created for all new users
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)


post_save.connect(create_user_profile, sender=User)


# make sure that profiles are created for all new users
def check_all_user_profiles(app, migration, method, **kwargs):
    if str(migration
           ) == 'user_profile:0002_add_userprofile' and method == 'forwards':
        UserProfile.objects.create_missing()


ran_migration.connect(check_all_user_profiles)
Exemple #2
0
def setup_handlers():
    ran_migration.connect(callback_ran_migration)
    pre_migrate.connect(callback_pre_migrate)
    post_migrate.connect(callback_post_migrate)
Exemple #3
0
    # private details
    mobile = models.CharField(max_length=30, blank=True)

    # other web presence
    facebook = models.CharField(max_length=30, blank=True)
    twitter  = models.CharField(max_length=30, blank=True)

    # location
    constituency = models.ForeignKey(
        'core.Place',
        limit_choices_to = {
            'kind__slug': 'constituency',
        },
        blank=True, null=True,
    )

    objects = UserProfileManager()


# make sure that profiles are created for all new users
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)

# make sure that profiles are created for all new users
def check_all_user_profiles(app, migration, method, **kwargs):
    if str(migration) == 'user_profile:0002_add_userprofile' and method == 'forwards':
        UserProfile.objects.create_missing()
ran_migration.connect(check_all_user_profiles)