Revision f568d0f4
b/snf-astakos-app/astakos/im/forms.py | ||
---|---|---|
754 | 754 |
|
755 | 755 |
class Meta: |
756 | 756 |
model = ProjectApplication |
757 |
#include = ( 'name', 'homepage', 'description', |
|
758 |
# 'start_date', 'end_date', 'comments') |
|
759 |
|
|
760 | 757 |
fields = ( 'name', 'homepage', 'description', |
761 | 758 |
'start_date', 'end_date', 'comments', |
762 | 759 |
'member_join_policy', 'member_leave_policy', |
... | ... | |
766 | 763 |
instance = kwargs.get('instance') |
767 | 764 |
self.precursor_application = instance |
768 | 765 |
super(ProjectApplicationForm, self).__init__(*args, **kwargs) |
766 |
# in case of new application remove closed join policy |
|
769 | 767 |
if not instance: |
770 |
# remove closed join policy |
|
771 | 768 |
policies = PROJECT_MEMBER_JOIN_POLICIES.copy() |
772 | 769 |
policies.pop('3') |
773 | 770 |
self.fields['member_join_policy'].choices = policies.iteritems() |
774 | 771 |
|
775 | 772 |
def clean_start_date(self): |
776 | 773 |
start_date = self.cleaned_data.get('start_date') |
777 |
now = datetime.now() |
|
778 |
if start_date and now - start_date > timedelta(days=1): |
|
779 |
raise forms.ValidationError( |
|
774 |
if not self.precursor_application: |
|
775 |
now = datetime.now() |
|
776 |
if start_date and now - start_date > timedelta(days=1): |
|
777 |
raise forms.ValidationError( |
|
780 | 778 |
_(astakos_messages.INVALID_PROJECT_START_DATE)) |
781 | 779 |
return start_date |
782 | 780 |
|
Also available in: Unified diff