Beispiel #1
0
    def save(self, user=None):
        if not user:
            user = User()

        if not user.pk:
            action_flag = ADDITION
        else:
            action_flag = CHANGE

        user = self.save_user(user)

        if has_active_business_profile(user):
            businessprofile = user.get_business_profile()
        else:
            businessprofile = BusinessProfile()
            businessprofile.creator = user.userprofile

        LogEntry.objects.log_action(
            user_id         = user.pk,
            content_type_id = ContentType.objects.get_for_model(user.userprofile).pk,
            object_id       = user.userprofile.pk,
            object_repr     = '(Frontend)' + force_unicode(user.userprofile),
            action_flag     = action_flag
        )

        businessprofile = self.save_businessprofile(businessprofile)

        if not has_active_business_profile(user):
            user.userprofile.active_profile = businessprofile
            user.userprofile.business_profiles.add(businessprofile)

        user.userprofile = self.save_userprofile(user.userprofile)

        return user