Commits

Federico Maggi committed bee59b8 Draft

added autocomplete search for M2M fields

Comments (0)

Files changed (2)

academic/publishing/admin.py

     verbose_name = 'Author'
     verbose_name_plural = 'Authors'
     model = Authorship
+    fields = (
+        'person' ,
+        'order',)
+    sortable_field_name = 'order'
     extra = 5
+    raw_id_fields = (
+        'person',)
+    autocomplete_lookup_fields = {
+        'fk': ['person',],
+    }
 
 class PublicationAdmin(admin.ModelAdmin):
     inlines = (AuthorshipInline,)
         'year',
 	'month')
 
+class PaperAdmin(PublicationAdmin):
+    pass
+
+class TechnicalReportAdmin(PaperAdmin):
+    fieldsets = (
+        (None, {
+                'fields': (
+                    'title',
+                    'year',
+                    'month',
+                    'fulltext',
+                    'abstract',
+                    'bibtex')
+                }),
+        (_('Extra information'), {
+                'fields': (
+                    'attachment',
+                    'notes',)}),
+        )
+    list_display = (
+        'author_list',
+        'title',
+        'year',
+	'month')
 admin.site.register(TechnicalReport, PublicationAdmin)
 
-class PaperAdmin(PublicationAdmin):
-    class Media:
-        css = {
-            'screen': (
-                'academic/admin/js/inline_author_helper.css',) }
-        js = (
-            'academic/admin/js/inline_author_helper.js', )
-    pass
 
 class ConferenceArticleAdmin(PaperAdmin):
     fieldsets = (
     verbose_name = 'Advisor'
     verbose_name_plural = 'Advisors'
     model = Advisorship
+    fields = (
+        'person',
+        'order',)
+    sortable_field_name = 'order'
     extra = 1
+    raw_id_fields = (
+        'person',)
+    autocomplete_lookup_fields = {
+        'fk': ['person',],
+    }
 
 class CoadvisorshipInline(admin.TabularInline):
     verbose_name = 'Coadvisor'
     verbose_name_plural = 'Coadvisors'
     model = Coadvisorship
+    fields = (
+        'person',
+        'order',)
+    sortable_field_name = 'order'
     extra = 1
+    raw_id_fields = (
+        'person',)
+    autocomplete_lookup_fields = {
+        'fk': ['person',],
+    }
 
 class ThesisAdmin(PublicationAdmin):
+    fieldsets = (
+        (None, {
+                'fields': (
+                    'title',
+                    'year',
+                    'month',
+                    'fulltext',
+                    'abstract',
+                    'bibtex')
+                }),
+        (_('Extra information'), {
+                'fields': (
+                    'attachment',
+                    'notes',)}),
+        )
     inlines = (
+        AuthorshipInline,
         AdvisorshipInline,
         CoadvisorshipInline)
 
     verbose_name = 'Reviewer'
     verbose_name_plural = 'Reviewers'
     model = Reviewing
+    fields = (
+        'person',
+        'order',)
+    sortable_field_name = 'order'
     extra = 1
+    raw_id_fields = (
+        'person',)
+    autocomplete_lookup_fields = {
+        'fk': ['person',],
+    }
 
 class PhdThesisAdmin(ThesisAdmin):
     inlines = (
+        AuthorshipInline,
         AdvisorshipInline,
         CoadvisorshipInline,
         ReviewingInline)

academic/publishing/models.py

         ordering = [
             'acronym',
             'name', ]
-        
+
     name = models.CharField(
         _('Name'),
         help_text=_('E.g., Recent Advances in Intrusion Detection'),
         unique_together = (
             'conference',
             'year',)
-    
+
     conference = models.ForeignKey(
         Conference)
     edition_number = models.PositiveSmallIntegerField(
     """
     A scientific publication.
     """
-    
+
     class Meta:
         unique_together = (
             ('title',
         ordering = [
 		'-year',
 		'-month']
-    
+
     title = models.CharField(
         _('Title'),
         max_length=1024)
     person = models.ForeignKey(Person)
     publication = models.ForeignKey(Publication)
     order = models.PositiveSmallIntegerField()
-    
+
 
 class Book(Publication):
     editors = models.ManyToManyField(
     class Meta:
         verbose_name_plural = _('Journal papers')
         verbose_name = _('Journal paper')
-    
+
     journal = models.ForeignKey(
         Journal)