コード例 #1
0
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
コード例 #2
0
ファイル: forms.py プロジェクト: shula/citytree
    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
コード例 #3
0
ファイル: models.py プロジェクト: shula/citytree
 def create_from_existing_user(user):
     return create_from_existing_base(User, UserProfile, user)
コード例 #4
0
ファイル: models.py プロジェクト: shula/citytree
 def create_from_existing_user_profile(up):
     return create_from_existing_base(UserProfile, Member, up)