def main():
    call = Comment.objects.all()
    count = 0
    for c in call:
        if CityComment.objects.filter(comment_ptr__pk=c.id).count() == 0:
            count += 1
            cc = create_from_existing_base(Comment, CityComment, c)
            cc.save()

    print "created %s CityComments with empty phones" % count
Esempio n. 2
0
    def get_comment_object(self):
        """
        Return a new (unsaved) comment object based on the information in this
        form. Assumes that the form is already validated and will throw a
        ValueError if not.

        Does not set any of the fields that would come from a Request object
        (i.e. ``user`` or ``ip_address``).
        """
        new_comment = super(CityCommentForm, self).get_comment_object()

        new = create_from_existing_base(base_class=Comment,
                inheritor_class=CityComment, obj=new_comment)
        new.phone = self.cleaned_data["phone"]

        return new
Esempio n. 3
0
 def create_from_existing_user(user):
     return create_from_existing_base(User, UserProfile, user)
Esempio n. 4
0
 def create_from_existing_user_profile(up):
     return create_from_existing_base(UserProfile, Member, up)