Add archive action and 'desarchive' on import
This commit is contained in:
parent
b4a14db118
commit
a0bcc21475
2 changed files with 10 additions and 0 deletions
|
|
@ -1,3 +1,6 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.db import models
|
||||
|
|
@ -18,6 +21,11 @@ class StudentAdmin(admin.ModelAdmin):
|
|||
search_fields = ('last_name', 'first_name', 'pcode', 'city', 'klass__name')
|
||||
fields = (('last_name', 'first_name'), 'street', ('pcode', 'city'), 'email',
|
||||
('tel', 'mobile'), 'birth_date', 'klass', 'archived')
|
||||
actions = ['archive']
|
||||
|
||||
def archive(self, request, queryset):
|
||||
queryset.update(archived=True)
|
||||
archive.short_description = "Marquer les étudiants sélectionnés comme archivés"
|
||||
|
||||
'''def get_readonly_fields(self, request, obj=None):
|
||||
if 'edit' not in request.GET:
|
||||
|
|
|
|||
|
|
@ -88,8 +88,10 @@ class Student(models.Model):
|
|||
except Klass.DoesNotExist:
|
||||
raise Exception("La classe '%s' n'existe pas encore" % values['klass'])
|
||||
values['klass'] = k
|
||||
# See if postal code included in city, and split them
|
||||
if 'city' in values and is_int(values['city'][:4]):
|
||||
values['pcode'], _, values['city'] = values['city'].partition(' ')
|
||||
values['archived'] = False
|
||||
return values
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue