예제 #1
0
from django.contrib import admin
from django import forms
from django.db import models
from micourses.models import *
from django.conf import settings
import reversion
from django.contrib.auth.models import User

# add reversion to User model
from reversion.helpers import patch_admin
patch_admin(User)

class UserChoiceField(forms.ModelChoiceField):
    def label_from_instance(self, obj):
        return "%s, %s" % (obj.last_name, obj.first_name)

class CourseUserChoiceField(forms.ModelChoiceField):
    def label_from_instance(self, obj):
        return "%s, %s" % (obj.user.last_name, obj.user.first_name)

class CourseGradeCategoryInline(admin.TabularInline):
    model = CourseGradeCategory

class CourseURLInline(admin.TabularInline):
    model = CourseURL

class CourseEnrollmentInline(admin.TabularInline):
    model = CourseEnrollment
    def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        if db_field.name == 'student':
            kwargs['form_class'] = CourseUserChoiceField
예제 #2
0
from prototype.admin.admmodel import ModelAdmin
from prototype.admin.admproject import ProjectAdmin

admin.site.register(Model, ModelAdmin)

# ------------------------------------------  Entity
from prototype.actions import  doEntityPrototype, doDiagram
from prototype.models import Entity



from prototype.models import ProtoVersionTitle
from protoLib.admin.admVersion import VersionAdm
  
admin.site.register( ProtoVersionTitle, VersionAdm  )
patch_admin(ProtoVersionTitle)



# class EntityResource(resources.ModelResource):
#     class Meta:
#         model = Entity

class EntityAdmin( admin.ModelAdmin ):
# class EntityAdmin( ImportExportActionModelAdmin ):
    actions = [ doEntityPrototype  ]
    # resource_class = EntityResource

admin.site.register(Entity, EntityAdmin )
patch_admin(Entity)
예제 #3
0
파일: apps.py 프로젝트: awaykened/site
    def ready(self):
        from . import signals

        from django.contrib.flatpages.models import FlatPage
        from reversion.helpers import patch_admin
        patch_admin(FlatPage)
예제 #4
0
# -*- coding: utf-8 -*-

from django.contrib  import admin
from reversion.helpers import patch_admin
import reversion


# -----------------------------------------   AddUser  

from django.contrib.auth.models import User, Group 
from protoExt.admin import UserProfileAdmin
# patch_admin(User)
patch_admin(Group)

from protoExt.actions import doAddUser, doAddUsers 

try: 
    admin.site.unregister( User ) 
except: 
    pass 

admin.site.register( User, UserProfileAdmin )


# -----------------------------------------   AddUser  

# from protoLib.models import UserProfile
# admin.site.register( UserProfile )
# patch_admin(UserProfile)

# -----------------------------------------     
예제 #5
0
                'fields': ['slug', 'meta_description']
            }
        ),
    ]


class FlatFrameAdmin(AppAdmin, admin.ModelAdmin):
    list_display = ('title', 'icon', 'slug', 'url', 'order', 'hidden')
    search_fields = ('title', 'icon', 'slug', 'url')
    list_filter = ['hidden']
    fieldsets = [
        (
            _('Base'), {
                'fields': ['title', 'icon', 'url', 'width', 'height', 'order', 'hidden']
            }
        ),
        (
            _('SEO'), {
                'fields': ['slug', 'meta_description']
            }
        ),
    ]


admin.site.register(FlatPage, FlatPageAdmin)
admin.site.register(FlatFrame, FlatFrameAdmin)


patch_admin(FlatPage)
patch_admin(FlatFrame)
            model = models.PhotoSize
            exclude = ('watermark',)


    class PhotoSizeAdmin(admin.ModelAdmin):
        form = PhotoSizeModelForm
        list_display = (
            'name', 'width', 'height', 'crop', 'pre_cache', 'effect', 'increment_count')
        fieldsets = (
            (None, {'fields': ('name', 'width', 'height', 'quality')}),
            ('Options', {'fields': ('upscale', 'crop', 'pre_cache', 'increment_count')}),
            ('Enhancements', {'fields': ('effect',)}),
        )

    admin.site.unregister(models.Watermark)
    admin.site.unregister(models.PhotoSize)
    admin.site.register(models.PhotoSize, PhotoSizeAdmin)


admin.site.unregister(models.Gallery)
admin.site.unregister(models.Photo)
admin.site.unregister(models.GalleryUpload)

admin.site.register(models.Gallery, GalleryAdmin)
admin.site.register(models.Photo, PhotoAdmin)

if 'reversion' in project_settings.INSTALLED_APPS:
    from reversion.helpers import patch_admin
    patch_admin(models.Gallery)
    patch_admin(models.Photo)
예제 #7
0
class CustomerAdmin(admin.ModelAdmin):
    search_fields = ('id', 'last_name', 'first_name',)
    filter_horizontal = ('subscriptions', 'classifications',)


class CustomerClassificationAdmin(admin.ModelAdmin):
    search_fields = ('code', 'description')

admin.site.register(Customer, CustomerAdmin)
# admin.site.register(Customer)
admin.site.register(CustomerSubscription)
admin.site.register(CustomerClassification, CustomerClassificationAdmin)
# admin.site.register(CustomerAchievement)
admin.site.register(Tier1Discipline)
admin.site.register(TimeZone)
admin.site.register(Topics)
admin.site.register(Countries)
admin.site.register(Regions)
admin.site.register(Web_Region)
admin.site.register(Web_Region_Country)


# Reversion Control for User Accounts

from reversion.helpers import patch_admin
from cms.models import User
from cms.models import Group

patch_admin(User)
patch_admin(Group)
예제 #8
0
from reversion.helpers import patch_admin

class BoxItemInline(admin.TabularInline):
    model=BoxItem
    fields = ['slot', 'accession', 'donor_id', 'tube_type', 'user', 'date', 'used']
    extra = 0

    formfield_overrides = {
        models.CharField: {'widget': TextInput(attrs={'size': 15})},
    }

class BoxAdmin(admin.ModelAdmin):
    fields = 'account', 'number', 'finish_date'
    list_filter = ['account']
    inlines = [BoxItemInline]

class BoxItemAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Box Info',        {'fields': ['box', 'slot']}),
        ('Sample Info',     {'fields': ['accession', 'donor_id', 'tube_type']}),
        ('Archive Info',    {'fields': ['user', 'date']}),
    ]

    list_display = ['slot', 'box', 'accession', 'donor_id', 'tube_type', 'user', 'date']
    list_filter = ['box__account']
    search_fields = ['box__number']

admin.site.register(Box, BoxAdmin)
admin.site.register(BoxItem, BoxItemAdmin)
patch_admin(BoxItem)
patch_admin(Box)
예제 #9
0
from django.contrib import admin

from reversion.helpers import patch_admin

from amanda.core.admin import AppAdmin
from amanda.flatblocks.models import FlatBlock


class FlatBlockAdmin(AppAdmin, admin.ModelAdmin):
    list_display = ['title']
    search_fields = ('title', 'content')


admin.site.register(FlatBlock, FlatBlockAdmin)


patch_admin(FlatBlock)
예제 #10
0
# -*- coding: utf-8 -*-

from django.contrib  import admin
from reversion.helpers import patch_admin

# -----------------------------------------     

from protoExt.models import ViewDefinition
admin.site.register(ViewDefinition)
patch_admin(ViewDefinition)

# -----------------------------------------     

from .models import CustomDefinition
admin.site.register(CustomDefinition)
patch_admin(CustomDefinition)

# -----------------------------------------