Ticket #16039: django.diff

File django.diff, 2.9 KB (added by asandroq, 12 years ago)

Patch for auth and contenttypes applications

  • django/contrib/auth/management/__init__.py

    diff -urx '*.pyc' Django-1.4/django/contrib/auth/management/__init__.py /usr/local/filewave/python/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py
    old new  
    2121    return perms + list(opts.permissions)
    2222
    2323
    24 def create_permissions(app, created_models, verbosity, **kwargs):
     24def create_permissions(app, created_models, verbosity, db, **kwargs):
    2525    from django.contrib.contenttypes.models import ContentType
    2626
    2727    app_models = get_models(app)
     
    3232    # The codenames and ctypes that should exist.
    3333    ctypes = set()
    3434    for klass in app_models:
    35         ctype = ContentType.objects.get_for_model(klass)
     35        ctype = ContentType.objects.db_manager(db).get_for_model(klass)
    3636        ctypes.add(ctype)
    3737        for perm in _get_all_permissions(klass._meta):
    3838            searched_perms.append((ctype, perm))
     
    4040    # Find all the Permissions that have a context_type for a model we're
    4141    # looking for.  We don't need to check for codenames since we already have
    4242    # a list of the ones we're going to create.
    43     all_perms = set(auth_app.Permission.objects.filter(
     43    all_perms = set(auth_app.Permission.objects.using(db).filter(
    4444        content_type__in=ctypes,
    4545    ).values_list(
    4646        "content_type", "codename"
     
    5151        for ctype, (codename, name) in searched_perms
    5252        if (ctype.pk, codename) not in all_perms
    5353    ]
    54     auth_app.Permission.objects.bulk_create(objs)
     54    auth_app.Permission.objects.using(db).bulk_create(objs)
    5555    if verbosity >= 2:
    5656        for obj in objs:
    5757            print "Adding permission '%s'" % obj
  • django/contrib/contenttypes/management.py

    diff -urx '*.pyc' Django-1.4/django/contrib/contenttypes/management.py /usr/local/filewave/python/lib/python2.7/site-packages/django/contrib/contenttypes/management.py
    old new  
    22from django.db.models import get_apps, get_models, signals
    33from django.utils.encoding import smart_unicode
    44
    5 def update_contenttypes(app, created_models, verbosity=2, **kwargs):
     5def update_contenttypes(app, created_models, verbosity, db, **kwargs):
    66    """
    77    Creates content types for models in the given app, removing any model
    88    entries that no longer have a matching model class.
     
    2020    # Get all the content types
    2121    content_types = dict(
    2222        (ct.model, ct)
    23         for ct in ContentType.objects.filter(app_label=app_label)
     23        for ct in ContentType.objects.using(db).filter(app_label=app_label)
    2424    )
    2525    to_remove = [
    2626        ct
Back to Top