Changeset 570

Show
Ignore:
Timestamp:
08/17/10 12:05:53 (3 years ago)
Author:
rafael.soares
Message:

added field helpers in new submission, close #169

Location:
trunk/opentrials/reviewapp
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/opentrials/reviewapp/forms.py

    r503 r570  
    44from opentrials.reviewapp.models import Remark 
    55from opentrials.reviewapp.models import UserProfile 
    6 from opentrials.reviewapp.models import Attachment 
     6from opentrials.reviewapp.models import Attachment, Submission 
    77from django import forms 
    88from django.utils.translation import ugettext as _ 
     
    1818 
    1919 
    20 class InitialTrialForm(forms.Form): 
     20class InitialTrialForm(ReviewModelForm): 
     21    class Meta: 
     22        model = Submission 
     23        exclude = ['primary_sponsor', 'trial', 'status', 'staff_note', 'title'] 
     24         
    2125    def __init__(self, *args, **kwargs): 
    2226        self.user = kwargs.pop('user', None) 
     
    2428        if self.user: 
    2529            self.fields['language'] = forms.ChoiceField(label=_('Submission language'),  
    26                         choices=settings.MANAGED_LANGUAGES_CHOICES, initial=self.user.get_profile().preferred_language) 
     30                        choices=settings.MANAGED_LANGUAGES_CHOICES,  
     31                        initial=self.user.get_profile().preferred_language) 
    2732             
    2833    form_title = _('Initial Trial Data') 
     
    3641                                 choices=settings.MANAGED_LANGUAGES_CHOICES) 
    3742     
    38 class PrimarySponsorForm(forms.ModelForm): 
     43class PrimarySponsorForm(ReviewModelForm): 
    3944    class Meta: 
    4045        model = Institution 
  • trunk/opentrials/reviewapp/templates/reviewapp/new_submission.html

    r489 r570  
    11{% extends "base.html" %} 
    22{% load i18n %} 
     3 
     4{% block extrahead %} 
     5        <script type="text/javascript"> 
     6            $(document).ready(function() { 
     7                $("select[multiple]").asmSelect({ 
     8                        addItemTarget: 'bottom', 
     9                        animate: true, 
     10                        highlight: true, 
     11                        sortable: false 
     12                }); 
     13                $('.dataTable th img').cluetip({sticky: true, closePosition: 'title',local:true, cursor: 'pointer'}); 
     14            }); 
     15        </script> 
     16{% endblock %} 
    317 
    418{% block stepmenu_top %} 
     
    1125 
    1226{% block body %} 
    13  
    14 <script type="text/javascript"> 
    15     //{# From http://stackoverflow.com/questions/501719/dynamically-adding-a-form-to-a-django-formset-with-ajax#669982 */ #} 
    16     function cloneMore(selector, type) { 
    17         var newElement = $(selector).clone(true); 
    18         var total = $('#id_' + type + '-TOTAL_FORMS').val(); 
    19         newElement.find(':input').each(function() { 
    20             var name = $(this).attr('name').replace('-' + (total-1) + '-','-' + total + '-'); 
    21             var id = 'id_' + name; 
    22             $(this).attr({'name': name, 'id': id}).val('').removeAttr('checked'); 
    23         }); 
    24         newElement.find('label').each(function() { 
    25             var newFor = $(this).attr('for').replace('-' + (total-1) + '-','-' + total + '-'); 
    26             $(this).attr('for', newFor); 
    27         }); 
    28         total++; 
    29         $('#id_' + type + '-TOTAL_FORMS').val(total); 
    30         newElement.css("display","none"); 
    31         $(selector).after(newElement); 
    32         newElement.show("fast"); 
    33     } 
    34  
    35     $(document).ready(function() { 
    36             $("input#addmore").click(function(){ 
    37                 cloneMore('table:last','form'); 
    38             }); 
    39             $("select[multiple]").asmSelect({ 
    40                     addItemTarget: 'bottom', 
    41                     animate: true, 
    42                     highlight: true, 
    43                     sortable: false 
    44             }); 
    45     }); 
    46 </script> 
    4727 
    4828<form method="post" action="/accounts/newsubmission/" enctype="multipart/form-data">{% csrf_token %}