|
@@ -1,4 +1,6 @@
|
|
from django.contrib import admin
|
|
from django.contrib import admin
|
|
|
|
+from django.core.urlresolvers import reverse
|
|
|
|
+from django.utils.safestring import mark_safe
|
|
|
|
|
|
from .models import (
|
|
from .models import (
|
|
Document, Cost, Good, CostUse, GoodUse, Service, ServiceUse)
|
|
Document, Cost, Good, CostUse, GoodUse, Service, ServiceUse)
|
|
@@ -7,7 +9,17 @@ from .models import (
|
|
@admin.register(Document)
|
|
@admin.register(Document)
|
|
class DocumentAdmin(admin.ModelAdmin):
|
|
class DocumentAdmin(admin.ModelAdmin):
|
|
list_display = ('name', 'date', 'type')
|
|
list_display = ('name', 'date', 'type')
|
|
-
|
|
|
|
|
|
+ actions = ['copy']
|
|
|
|
+
|
|
|
|
+ def copy(self, request, queryset):
|
|
|
|
+ for i in queryset.all():
|
|
|
|
+ new = i.copy()
|
|
|
|
+ edit_url = reverse('admin:costs_document_change', args=(new.pk,))
|
|
|
|
+ self.message_user(
|
|
|
|
+ request, mark_safe(
|
|
|
|
+ "{} copié, pensez à <a href=\"{}\">L'éditer</a>".format(
|
|
|
|
+ new, edit_url)))
|
|
|
|
+ copy.short_description = 'Copier'
|
|
|
|
|
|
class GoodUseInline(admin.TabularInline):
|
|
class GoodUseInline(admin.TabularInline):
|
|
model = GoodUse
|
|
model = GoodUse
|