class ContributionInline(admin.TabularInline): """Contributions of repository.""" model = Contribution extra = 0 class RepositoryAdmin(base.ModelAdmin): """Repository representation.""" fieldsets = ( (None, { 'fields': ( 'is_tracked', 'is_visible', 'name', 'full_name', 'html_url', 'organization', ), }), ) inlines = (ContributionInline,) list_display = ('id', 'name', 'organization', 'is_tracked', 'is_visible') list_filter = ('organization',) search_fields = ('name',) actions = ['change_tracking', 'change_visibility'] site.register(Repository, RepositoryAdmin)
from contributors.admin import base from contributors.admin.custom import site from contributors.models import Project class ProjectAdmin(base.ModelAdmin): """Project representation.""" fieldsets = ((None, { 'fields': ( 'name', 'description', 'html_url', ), }), ) list_display = ('id', 'name') search_fields = ('name', ) site.register(Project, ProjectAdmin)
from django.contrib.auth.admin import UserAdmin from auth.forms import UserChangeForm, UserCreationForm from auth.models import SiteUser from contributors.admin.custom import site class SiteUserAdmin(UserAdmin): """Site user representation.""" model = SiteUser add_form = UserCreationForm form = UserChangeForm site.register(SiteUser, SiteUserAdmin)
class CommitStatsInline(admin.StackedInline): """Commit statistics.""" model = CommitStats extra = 0 class ContributionAdmin(admin.ModelAdmin): """Contribution representation.""" inlines = (CommitStatsInline, ) list_display = ( 'id', 'repository', 'contributor', 'type', 'html_url', 'created_at', ) list_filter = ( 'repository__organization', 'repository', 'contributor', 'type', ) site.register(Contribution, ContributionAdmin)
from django.contrib import admin from contributors.admin.custom import site from contributors.models import Organization, Repository class RepositoryInline(admin.TabularInline): """Repositories of organization.""" model = Repository extra = 0 class OrganizationAdmin(admin.ModelAdmin): """Organization representation.""" inlines = (RepositoryInline,) list_display = ('id', 'name', 'is_tracked') search_fields = ('name',) site.register(Organization, OrganizationAdmin)
from contributors.admin import base from contributors.admin.custom import site from contributors.models import Contributor class ContributorAdmin(base.ModelAdmin): """Contributor representation.""" fieldsets = ( (None, { 'fields': ( 'is_tracked', 'is_visible', 'login', ), }), ('Additional info', { 'fields': ( 'name', 'html_url', 'avatar_url', ), }), ) list_display = ('id', 'login', 'name', 'is_tracked', 'is_visible') search_fields = ('login', 'name') actions = ['change_tracking', 'change_visibility'] site.register(Contributor, ContributorAdmin)