Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py	(revision 13217)
@@ -92,6 +92,11 @@
     def containers(self):
         if self.layout.isAuthenticated():
-            return self.context.values()
-        return [value for value in self.context.values() if not value.hidden]
+            values = sorted([container for container in self.context.values()],
+                            key=lambda value: value.enddate)
+            return values
+        values = sorted([container for container in self.context.values()
+                         if not container.hidden],
+                        key=lambda value: value.enddate)
+        return values
 
 class ApplicantsSearchPage(KofaPage):
@@ -352,5 +357,5 @@
     @property
     def showApplicants(self):
-        if len(self.context) < 5000:
+        if self.context.counts[1] < 1000:
             return True
         return False
@@ -469,4 +474,42 @@
         self.redirect(
             self.url(self.context[applicant.application_number], 'index'))
+        return
+
+class ApplicantsContainerPrefillFormPage(KofaAddFormPage):
+    """Add-form to pre-fill applicants containers.
+    """
+    grok.context(IApplicantsContainer)
+    grok.require('waeup.manageApplication')
+    grok.name('prefill')
+    grok.template('prefill_container')
+    label = _('Pre-fill container')
+    pnav = 3
+    doclink = DOCLINK + '/applicants.html'
+
+    def update(self):
+        if self.context.mode == 'update':
+            self.flash(_('Container must be in create mode to be pre-filled.'),
+                type='danger')
+            self.redirect(self.url(self.context))
+            return
+        super(ApplicantsContainerPrefillFormPage, self).update()
+        return
+
+    @action(_('Pre-fill now'), style='primary')
+    def addApplicants(self, **data):
+        form = self.request.form
+        if 'number' in form and form['number']:
+            number = int(form['number'])
+        for i in range(number):
+            applicant = createObject(u'waeup.Applicant')
+            self.context.addApplicant(applicant)
+        self.flash(_('%s application records created.' % number))
+        self.context.writeLogMessage(self, '%s applicants created' % (number))
+        self.redirect(self.url(self.context, 'index'))
+        return
+
+    @action(_('Cancel'), validator=NullValidator)
+    def cancel(self, **data):
+        self.redirect(self.url(self.context))
         return
 
@@ -1150,11 +1193,8 @@
             return
         if self.context.mode == 'create':
-            # Check if there are unused records which can be taken
-            cat = getUtility(ICatalog, name='applicants_catalog')
-            results = list(
-               cat.searchResults(record_used=(False, False)))
-            if results:
-                applicant = results[0]
-            else:
+            # Check if there are unused records in this container which
+            # can be taken
+            applicant = self.context.first_unused
+            if applicant is None:
                 # Add applicant
                 applicant = createObject(u'waeup.Applicant')
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantscontainermanagepage.pt
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantscontainermanagepage.pt	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantscontainermanagepage.pt	(revision 13217)
@@ -35,4 +35,6 @@
     </div>
     <div id="tab2" class="tab-pane">
+    <br />
+    This container contains <span tal:replace="python: context.counts[0]-context.counts[1]">UNUSED</span> unused pre-filled records.<br />
     <tal:showApplicants  condition="view/showApplicants">
       <br />
@@ -53,5 +55,5 @@
         </thead>
         <tbody>
-          <tr tal:repeat="appl context/values">
+          <tr tal:repeat="appl python:[appl for appl in context.values() if appl.container_code.endswith('+')]">
             <td>
               <input type="checkbox" name="val_id" tal:attributes="value appl/__name__" />
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantsrootmanagepage.pt
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantsrootmanagepage.pt	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantsrootmanagepage.pt	(revision 13217)
@@ -54,4 +54,6 @@
             <th i18n:translate="">Records
             </th>
+            <th i18n:translate="">Application Deadline
+            </th>
           </tr>
         </thead>
@@ -65,5 +67,7 @@
                 tal:content="entry/__name__">CODE</a> </td>
             <td tal:content="entry/title">TITLE</td>
-            <td tal:content="python:len(entry)">YEAR</td>
+            <td tal:content="python: len(entry)">RECORDS</td>
+            <td><span tal:content="python: layout.formatDatetime(entry.enddate)">
+                END</span></td>
           </tr>
         </tbody>
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/prefill_container.pt
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/prefill_container.pt	(revision 13217)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/prefill_container.pt	(revision 13217)
@@ -0,0 +1,22 @@
+<form action="." tal:attributes="action request/URL" method="post"
+      i18n:domain="waeup.kofa" enctype="multipart/form-data"
+      autocomplete="off">
+
+    <br />
+
+    <label i18n:translate="">
+     Pre-fill '<span tal:replace="context/code">CODE</span>' container with
+    </label>
+    <select id="number" name="number" class="form-control half">
+      <option value="10" i18n:translate="">10 empty records</option>
+      <option value="100" i18n:translate="">100 empty records</option>
+      <option value="1000" i18n:translate="">1000 empty records</option>
+      <option value="10000" i18n:translate="">10000 empty records</option>
+    </select>
+    <br /><br />
+    <div tal:condition="view/availableActions">
+      <input tal:repeat="action view/actions"
+             tal:replace="structure action/render"
+             />
+    </div>
+</form>
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py	(revision 13217)
@@ -27,4 +27,5 @@
 from zope.component.factory import Factory
 from zope.component.interfaces import IFactory
+from zope.catalog.interfaces import ICatalog
 from waeup.kofa.interfaces import MessageFactory as _
 from waeup.kofa.applicants.interfaces import (
@@ -67,4 +68,23 @@
             applicant.applicant_id = applicant_id
         self[applicant.application_number] = applicant
+        return
+
+    @property
+    def counts(self):
+        total = len(self)
+        code = self.code + '+'
+        cat = getUtility(ICatalog, name='applicants_catalog')
+        results = list(
+           cat.searchResults(container_code=(code, code)))
+        return len(self), len(results)
+
+    @property
+    def first_unused(self):
+        code = self.code + '-'
+        cat = getUtility(ICatalog, name='applicants_catalog')
+        results = list(
+           cat.searchResults(container_code=(code, code)))
+        if results:
+            return results[0]
         return
 
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py	(revision 13217)
@@ -467,4 +467,39 @@
         return
 
+    def test_prefill_container(self):
+        # Managers can pre-fill containers in create mode
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.prefill_path = self.container_path + '/prefill'
+        self.container_manage_path = self.container_path + '/@@manage'
+        self.browser.open(self.container_manage_path)
+        self.browser.getLink("Pre-fill").click()
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.url, self.prefill_path)
+        self.browser.getControl(name="number").value = ['10']
+        self.browser.getControl("Pre-fill").click()
+        self.assertTrue('10 application records created.' in self.browser.contents)
+        self.browser.open(self.container_manage_path)
+        self.assertTrue('This container contains 10 unused pre-filled records.'
+            in self.browser.contents)
+        self.assertEqual(self.applicantscontainer.counts[0], 11)
+        self.assertEqual(self.applicantscontainer.counts[1], 1)
+        # In update mode we can't pre-fill the container
+        self.applicantscontainer.mode = 'update'
+        self.browser.open(self.container_manage_path)
+        self.browser.getLink("Pre-fill").click()
+        self.assertTrue('Container must be in create mode to be pre-filled.'
+            in self.browser.contents)
+        self.browser.open(self.manage_root_path)
+        # Number of total records is 11
+        self.assertTrue('<td>11</td>' in self.browser.contents)
+        # The statistics have not changed
+        self.browser.open(self.container_path)
+        self.browser.getLink("Container statistics").click()
+        self.assertTrue('<td>1</td>' in self.browser.contents)
+        self.assertEqual(self.applicantscontainer.statistics[0],
+            {'not admitted': 0, 'started': 0, 'created': 0,
+            'admitted': 0, 'submitted': 0, 'initialized': 1, 'paid': 0})
+        return
+
 class ApplicantUITests(ApplicantsFullSetup):
     # Tests for uploading/browsing the passport image of appplicants
@@ -1235,5 +1270,5 @@
         uu_applicant = createObject('waeup.Applicant')
         self.app['applicants'][container_name_1].addApplicant(uu_applicant)
-        self.assertFalse(uu_applicant.record_used)
+        self.assertEqual(uu_applicant.container_code, container_name_1 + '-')
         self.assertEqual(len(self.app['applicants'][container_name_1]), 2)
         self.browser.open(self.container_path)
@@ -1251,5 +1286,5 @@
         # ... and the existing, formerly unused record has been used instead
         self.assertEqual(uu_applicant.lastname, 'Kurios')
-        self.assertTrue(uu_applicant.record_used)
+        self.assertEqual(uu_applicant.container_code, container_name_1 + '+')
         return
 
Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py	(revision 13216)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py	(revision 13217)
@@ -116,6 +116,15 @@
     target = 'addapplicant'
 
+class ApplicantsContainerPrefillActionButton(AddActionButton):
+    grok.order(2)
+    grok.context(IApplicantsContainer)
+    grok.view(ApplicantsContainerManageFormPage)
+    grok.require('waeup.manageApplication')
+    icon = 'actionicon_bucketfill.png'
+    text = _('Pre-fill container')
+    target = 'prefill'
+
 class ApplicantsContainerStatisticsActionButton(ManageActionButton):
-    grok.order(2)
+    grok.order(3)
     grok.context(IApplicantsContainer)
     grok.view(ApplicantsContainerManageFormPage)
@@ -127,5 +136,5 @@
 class ApplicantsContainerStatisticsActionButton2(
         ApplicantsContainerStatisticsActionButton):
-    grok.order(3)
+    grok.order(4)
     grok.view(ApplicantsContainerPage)
 
