Commit 88175c09a80d4691c3e82f2a4c72e613f9a8cf9f

Authored by Felipe Henrique de Almeida Bormann
2 parents 99ce3212 ca2a40c2

Merge branch 'master' into dev

amadeus/settings.py
... ... @@ -14,6 +14,8 @@ import os
14 14  
15 15 import dj_database_url
16 16  
  17 +from django.conf.global_settings import DATETIME_INPUT_FORMATS, DATE_INPUT_FORMATS
  18 +
17 19 db_from_ev = dj_database_url.config(conn_max_age=500)
18 20  
19 21  
... ... @@ -226,6 +228,10 @@ OAUTH2_PROVIDER = {
226 228 #API CONFIG ENDS
227 229  
228 230  
  231 +#For date purposes
  232 +DATETIME_INPUT_FORMATS.append('%d/%m/%y')
  233 +DATE_INPUT_FORMATS.append('%d/%m/%y')
  234 +
229 235 #s3direct
230 236  
231 237 # AWS keys
... ...
courses/forms.py
1   -from django import forms from django.utils.translation import ugettext_lazy as _ from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial from s3direct.widgets import S3DirectWidget from django_summernote.widgets import SummernoteWidget
2   -class CategoryCourseForm(forms.ModelForm):
3   - class Meta: model = CourseCategory fields = ('name',) labels = { 'name': _('Name') } help_texts = { 'name': _('CourseCategory name') }
4   -class CourseForm(forms.ModelForm):
5   - class Meta: model = Course fields = ('name', 'category', 'coordenator','public') labels = { 'name': _('Name'), 'category': _('Category'), 'coordenator': _('Coordenator'), 'public':_('Public'), } help_texts = { 'name': _('Course name'), 'coordenator': _('Course Coordenator'), 'public':_('To define if the course can be accessed by people not registered'), } widgets = {
6   - 'category': forms.Select(), 'coordenator': forms.Select(), }
7   -class UpdateCourseForm(CourseForm):
8   - class Meta: model = Course fields = ('name', 'category', 'coordenator','public') labels = { 'name': _('Name'), 'category': _('Category'), 'coordenator': _('Coordenator'), 'public':_('Public'), } help_texts = { 'name': _('Course name'), 'coordenator': _('Course Coordenator'), 'public':_('To define if the course can be accessed by people not registered'), } widgets = { 'category': forms.Select(), 'coordenator': forms.Select(), } class SubjectForm(forms.ModelForm): def clean_end_date(self): end_date = self.cleaned_data['end_date'] if('init_date' in self.cleaned_data): init_date = self.cleaned_data['init_date'] if init_date and end_date and end_date < init_date: raise forms.ValidationError(_('The end date may not be before the start date.')) return end_date
9   - class Meta: model = Subject fields = ('name', 'description','init_date', 'end_date', 'visible',) labels = { 'name': _('Name'), 'description': _('Description'), 'init_date': _('Start date'), 'end_date': _('End date'), 'visible': _('Is it visible?'), } help_texts = { 'name': _("Subjects's name"), 'description': _("Subjects's description"), 'init_date': _('Start date of the subject'), 'end_date': _('End date of the subject'), 'visible': _('Is the subject visible?'), } widgets = { 'description':SummernoteWidget(), }
10   -class TopicForm(forms.ModelForm):
11   - class Meta: model = Topic fields = ('name', 'description','visible') labels = { 'name': _('Name'), 'description': _('Description'), 'visible': _('Is the topic visible?'), } help_texts = { 'name': _("Topic's name"), 'description': _("Topic's description"), 'visible': _('Is it visible?'), } widgets = { 'description':SummernoteWidget(), }
12   -class ActivityFileForm(forms.ModelForm): name = forms.CharField( required=False, max_length=100, widget=forms.TextInput(attrs={ 'placeholder': 'Nome', 'class': 'form-control' },)) pdf = forms.URLField(required=True, widget=S3DirectWidget( dest='activitys', html=(
13   - '<div class="s3direct" data-policy-url="{policy_url}">' ' <a class="file-link" target="_blank" href="{file_url}">{file_name}</a>' ' <a class="file-remove" href="#remove">Remover</a>' ' <input class="file-url" type="hidden" value="{file_url}" id="{element_id}" name="{name}" />' ' <input class="file-dest" type="hidden" value="{dest}">' ' <input class="file-input" type="file" />' ' <div class="progress">' ' <div class="progress-bar progress-bar-success progress-bar-striped active bar">' ' </div>' ' </div>' '</div>' )))
14   - class Meta: model = ActivityFile fields = ['pdf','name']
15   -class ActivityForm(forms.ModelForm): class Meta: model = Activity fields = ['topic', 'limit_date', 'students','all_students']
16   -class FileMaterialForm(forms.ModelForm): class Meta: model = FileMaterial fields = ['name', 'file']
17   -class LinkMaterialForm(forms.ModelForm): class Meta: model = LinkMaterial fields = ['material', 'name', 'description','url']
18 1 \ No newline at end of file
  2 +
  3 +
  4 +from amadeus import settings
  5 +from django import forms
  6 +from django.utils.translation import ugettext_lazy as _
  7 +from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial
  8 +from s3direct.widgets import S3DirectWidget
  9 +from django_summernote.widgets import SummernoteWidget
  10 +
  11 +class CategoryCourseForm(forms.ModelForm):
  12 +
  13 + class Meta:
  14 + model = CourseCategory
  15 + fields = ('name',)
  16 + labels = {
  17 + 'name': _('Name')
  18 + }
  19 + help_texts = {
  20 + 'name': _('CourseCategory name')
  21 + }
  22 +
  23 +class CourseForm(forms.ModelForm):
  24 +
  25 + class Meta:
  26 + model = Course
  27 + fields = ('name', 'category', 'coordenator','public')
  28 + labels = {
  29 + 'name': _('Name'),
  30 + 'category': _('Category'),
  31 + 'coordenator': _('Coordenator'),
  32 + 'public':_('Public'),
  33 + }
  34 + help_texts = {
  35 + 'name': _('Course name'),
  36 + 'coordenator': _('Course Coordenator'),
  37 + 'public':_('To define if the course can be accessed by people not registered'),
  38 + }
  39 + widgets = {
  40 + 'category': forms.Select(),
  41 + 'coordenator': forms.Select(),
  42 + }
  43 +
  44 +class UpdateCourseForm(CourseForm):
  45 +
  46 + class Meta:
  47 + model = Course
  48 + fields = ('name', 'category', 'coordenator','public')
  49 + labels = {
  50 + 'name': _('Name'),
  51 + 'category': _('Category'),
  52 + 'coordenator': _('Coordenator'),
  53 + 'public':_('Public'),
  54 + }
  55 + help_texts = {
  56 + 'name': _('Course name'),
  57 + 'coordenator': _('Course Coordenator'),
  58 + 'public':_('To define if the course can be accessed by people not registered'),
  59 + }
  60 + widgets = {
  61 + 'category': forms.Select(),
  62 + 'coordenator': forms.Select(),
  63 + }
  64 +
  65 +class SubjectForm(forms.ModelForm):
  66 + def clean_end_date(self):
  67 + end_date = self.cleaned_data['end_date']
  68 + if('init_date' in self.cleaned_data):
  69 + init_date = self.cleaned_data['init_date']
  70 + if init_date and end_date and end_date < init_date:
  71 + raise forms.ValidationError(_('The end date may not be before the start date.'))
  72 + return end_date
  73 +
  74 + class Meta:
  75 + model = Subject
  76 + fields = ('name', 'description','init_date', 'end_date', 'visible',)
  77 + labels = {
  78 + 'name': _('Name'),
  79 + 'description': _('Description'),
  80 + 'init_date': _('Start date'),
  81 + 'end_date': _('End date'),
  82 + 'visible': _('Is it visible?'),
  83 + }
  84 + help_texts = {
  85 + 'name': _("Subjects's name"),
  86 + 'description': _("Subjects's description"),
  87 + 'init_date': _('Start date of the subject'),
  88 + 'end_date': _('End date of the subject'),
  89 + 'visible': _('Is the subject visible?'),
  90 + }
  91 + widgets = {
  92 + 'description':SummernoteWidget(),
  93 + }
  94 +
  95 +class TopicForm(forms.ModelForm):
  96 +
  97 + class Meta:
  98 + model = Topic
  99 + fields = ('name', 'description','visible')
  100 + labels = {
  101 + 'name': _('Name'),
  102 + 'description': _('Description'),
  103 + 'visible': _('Is the topic visible?'),
  104 + }
  105 + help_texts = {
  106 + 'name': _("Topic's name"),
  107 + 'description': _("Topic's description"),
  108 + 'visible': _('Is it visible?'),
  109 + }
  110 + widgets = {
  111 + 'description':SummernoteWidget(),
  112 + }
  113 +
  114 +class ActivityFileForm(forms.ModelForm):
  115 + name = forms.CharField(
  116 + required=False,
  117 + max_length=100,
  118 + widget=forms.TextInput(attrs={
  119 + 'placeholder': 'Nome',
  120 + 'class': 'form-control'
  121 + },))
  122 + pdf = forms.URLField(required=True, widget=S3DirectWidget(
  123 + dest='activitys',
  124 + html=(
  125 + '<div class="s3direct" data-policy-url="{policy_url}">'
  126 + ' <a class="file-link" target="_blank" href="{file_url}">{file_name}</a>'
  127 + ' <a class="file-remove" href="#remove">Remover</a>'
  128 + ' <input class="file-url" type="hidden" value="{file_url}" id="{element_id}" name="{name}" />'
  129 + ' <input class="file-dest" type="hidden" value="{dest}">'
  130 + ' <input class="file-input" type="file" />'
  131 + ' <div class="progress">'
  132 + ' <div class="progress-bar progress-bar-success progress-bar-striped active bar">'
  133 + ' </div>'
  134 + ' </div>'
  135 + '</div>'
  136 + )))
  137 +
  138 + class Meta:
  139 + model = ActivityFile
  140 + fields = ['pdf','name']
  141 +
  142 +class ActivityForm(forms.ModelForm):
  143 + class Meta:
  144 + model = Activity
  145 + fields = ['topic', 'limit_date', 'students','all_students']
  146 +
  147 +class FileMaterialForm(forms.ModelForm):
  148 + class Meta:
  149 + model = FileMaterial
  150 + fields = ['name', 'file']
  151 +
  152 +class LinkMaterialForm(forms.ModelForm):
  153 + class Meta:
  154 + model = LinkMaterial
  155 + fields = ['material', 'name', 'description','url']
  156 +
  157 +>>>>>>> dev
... ...
courses/templates/course/create.html
... ... @@ -18,7 +18,7 @@
18 18 <label for="{{ field.auto_id }}">{{ field.label }}</label>
19 19 {% endif %}
20 20 {% if field.auto_id == 'id_init_register_date' or field.auto_id == 'id_end_register_date' or field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%}
21   - <input type="text" class="form-control date-picker" name="{{field.name}}" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}">
  21 + <input type="text" class="form-control date-picker" name="{{field.name}}" value="{{field.value|date}}" min="{{now|date:'SHORT_DATE_FORMAT'}}">
22 22 {% elif field.auto_id == 'id_public' %}
23 23 <div class="checkbox">
24 24 <label>
... ...
courses/templates/course/datepicker.html
1   -<div class="input-append date" id="dp2" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
  1 +<div class="input-append date" id="dp2" data-date="12-02-2012" >
2 2 <input class="span2" size="16" type="text">
3 3 <span class="add-on"><i class="icon-th"></i></span>
4 4 </div>
5 5 \ No newline at end of file
... ...
courses/views.py
... ... @@ -158,7 +158,6 @@ class CreateCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationM
158 158 def form_valid(self, form):
159 159 self.object = form.save()
160 160 self.object.professors.add(self.request.user)
161   -
162 161 self.log_context['course_id'] = self.object.id
163 162 self.log_context['course_name'] = self.object.name
164 163 self.log_context['course_slug'] = self.object.slug
... ...