示例#1
0
    max_num = 1
    can_delete = False
    fields = ('display_name', 'website', 'bio')


class LinkInline(admin.TabularInline):
    model = Link
    extra = 0
    max_num = 0
    fields = ('banner', 'banner_variation', 'destination', 'link_clicks')
    readonly_fields = ('banner', 'banner_variation', 'destination', 'link_clicks')

    def banner(self, link):
        return link.banner

    def banner_variation(self, link):
        return mark_safe(link.banner_variation)

    def link_clicks(self, link):
        return link.link_clicks


class UserAdmin(auth.admin.UserAdmin):
    """Configuration for the user admin pages."""
    list_display = ['display_name', 'email', 'is_staff', 'username']
    search_fields = ['email', 'userprofile__display_name', 'username']
    inlines = [UserProfileInline, LinkInline]


admin_site.register(auth.models.User, UserAdmin)
示例#2
0

class LinkAdmin(BaseModelAdmin):
    list_display = ('banner', 'banner_type', 'banner_variation', 'user_name',
                    'user_email', 'link_clicks', 'created')
    search_fields = ('id', 'user__userprofile__display_name', 'user__email')

    def user_name(self, link):
        return link.user.display_name

    def user_email(self, link):
        return link.user.email

    def banner_type(self, link):
        if link.is_image_link:
            return 'Image Link'
        elif link.is_text_link:
            return 'Text Link'
        elif link.is_upgrade_link:
            return 'Upgrade Link'
        else:
            return 'Unknown'

    def banner_variation(self, link):
        return link.banner_variation

    banner_variation.allow_tags = True


admin_site.register(Link, LinkAdmin)
示例#3
0
class FacebookBannerLocaleInline(admin.TabularInline):
    model = FacebookBannerLocale
    extra = 0
    fields = ('locale', 'image', 'thumbnail')
    formfield_overrides = {models.ImageField: {'widget': ImageWidget}}


class FacebookBannerAdmin(BaseModelAdmin):
    list_display = ('name', 'link', '_alt_text')
    search_fields = ('name', 'link', '_alt_text')
    fieldsets = (
        (None, {'fields': ('name', 'link', '_alt_text')}),
        ('Images', {'fields': ('image', 'thumbnail')}),
    )
    inlines = [FacebookBannerLocaleInline]
admin_site.register(FacebookBanner, FacebookBannerAdmin)


class FacebookBannerInstanceAdmin(BaseModelAdmin):
    list_display = ('text', 'banner', 'user', 'locale', 'can_be_an_ad',
                    'use_profile_image', 'created', 'total_clicks',
                    'review_status')
    search_fields = ('text', 'banner__name', 'user__full_name', 'id')
    list_filter = ('banner', 'created', 'processed', 'review_status',
                   'total_clicks')
    readonly_fields = ('created', 'total_clicks')
    fieldsets = (
        (None, {
            'fields': ('user', 'banner', 'locale', 'text', 'created',
                       'total_clicks')
        }),
示例#4
0
class FacebookBannerAdmin(BaseModelAdmin):
    list_display = ('name', 'link', '_alt_text')
    search_fields = ('name', 'link', '_alt_text')
    fieldsets = (
        (None, {
            'fields': ('name', 'link', '_alt_text')
        }),
        ('Images', {
            'fields': ('image', 'thumbnail')
        }),
    )
    inlines = [FacebookBannerLocaleInline]


admin_site.register(FacebookBanner, FacebookBannerAdmin)


class FacebookBannerInstanceAdmin(BaseModelAdmin):
    list_display = ('text', 'banner', 'user', 'locale', 'can_be_an_ad',
                    'use_profile_image', 'created', 'total_clicks',
                    'review_status')
    search_fields = ('text', 'banner__name', 'user__full_name', 'id')
    list_filter = ('banner', 'created', 'processed', 'review_status',
                   'total_clicks')
    readonly_fields = ('created', 'total_clicks')
    fieldsets = (
        (None, {
            'fields':
            ('user', 'banner', 'locale', 'text', 'created', 'total_clicks')
        }),
示例#5
0
    can_delete = False
    fields = ('display_name', 'website', 'bio')


class LinkInline(admin.TabularInline):
    model = Link
    extra = 0
    max_num = 0
    fields = ('banner', 'banner_variation', 'destination', 'link_clicks')
    readonly_fields = ('banner', 'banner_variation', 'destination',
                       'link_clicks')

    def banner(self, link):
        return link.banner

    def banner_variation(self, link):
        return mark_safe(link.banner_variation)

    def link_clicks(self, link):
        return link.link_clicks


class UserAdmin(auth.admin.UserAdmin):
    """Configuration for the user admin pages."""
    list_display = ['display_name', 'email', 'is_staff', 'username']
    search_fields = ['email', 'userprofile__display_name', 'username']
    inlines = [UserProfileInline, LinkInline]


admin_site.register(auth.models.User, UserAdmin)
示例#6
0
from affiliates.links.models import Link


class LinkAdmin(BaseModelAdmin):
    list_display = ('banner', 'banner_type', 'banner_variation', 'user_name', 'user_email',
                    'link_clicks', 'created')
    search_fields = ('id', 'user__userprofile__display_name', 'user__email')

    def user_name(self, link):
        return link.user.display_name

    def user_email(self, link):
        return link.user.email

    def banner_type(self, link):
        if link.is_image_link:
            return 'Image Link'
        elif link.is_text_link:
            return 'Text Link'
        elif link.is_upgrade_link:
            return 'Upgrade Link'
        else:
            return 'Unknown'

    def banner_variation(self, link):
        return link.banner_variation
    banner_variation.allow_tags = True


admin_site.register(Link, LinkAdmin)
示例#7
0
                    'link_clicks')
    fields = ('name', 'category', 'visible', 'destination', 'created',
              'modified')
    readonly_fields = ('created', 'modified')
    search_fields = ('name', 'destination', 'category__name')
    inlines = (TextVariationInline, )


class FirefoxUpgradeBannerVariationInline(admin.TabularInline):
    model = models.FirefoxUpgradeBannerVariation
    fields = ('color', 'locale', 'image', 'upgrade_image')
    formfield_overrides = {ImageField: {'widget': ImageWidget}}
    extra = 0


class FirefoxUpgradeBannerModelAdmin(BaseModelAdmin):
    list_display = ('name', 'category', 'destination', 'visible',
                    'link_clicks')
    fields = ('name', 'category', 'destination', 'visible', 'created',
              'modified')
    readonly_fields = ('created', 'modified')
    search_fields = ('name', 'destination', 'category__name')
    inlines = (FirefoxUpgradeBannerVariationInline, )


admin_site.register(models.Category, CategoryModelAdmin)
admin_site.register(models.ImageBanner, ImageBannerModelAdmin)
admin_site.register(models.TextBanner, TextBannerModelAdmin)
admin_site.register(models.FirefoxUpgradeBanner,
                    FirefoxUpgradeBannerModelAdmin)
示例#8
0
    extra = 0


class TextBannerModelAdmin(BaseModelAdmin):
    list_display = ('name', 'category', 'visible', 'destination')
    fields = ('name', 'category', 'visible', 'destination', 'created', 'modified')
    readonly_fields = ('created', 'modified')
    search_fields = ('name', 'destination', 'category__name')
    inlines = (TextVariationInline,)


class FirefoxUpgradeBannerVariationInline(admin.TabularInline):
    model = models.FirefoxUpgradeBannerVariation
    fields = ('color', 'locale', 'image', 'upgrade_image')
    formfield_overrides = {ImageField: {'widget': ImageWidget}}
    extra = 0


class FirefoxUpgradeBannerModelAdmin(BaseModelAdmin):
    list_display = ('name', 'category', 'destination', 'visible')
    fields = ('name', 'category', 'destination', 'visible', 'created', 'modified')
    readonly_fields = ('created', 'modified')
    search_fields = ('name', 'destination', 'category__name')
    inlines = (FirefoxUpgradeBannerVariationInline,)


admin_site.register(models.Category, CategoryModelAdmin)
admin_site.register(models.ImageBanner, ImageBannerModelAdmin)
admin_site.register(models.TextBanner, TextBannerModelAdmin)
admin_site.register(models.FirefoxUpgradeBanner, FirefoxUpgradeBannerModelAdmin)