From c943495e42fd09477a5a9c14038f7c233fc6e384 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 19 Jan 2017 21:50:12 -0200 Subject: [PATCH] Adding webpage form (Not working yet/Adjusts to make) --- amadeus/settings.py | 2 ++ amadeus/static/js/jquery.formset.js | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ amadeus/static/js/topics.js | 10 +++++++++- amadeus/urls.py | 1 + pendencies/__init__.py | 0 pendencies/admin.py | 3 +++ pendencies/apps.py | 5 +++++ pendencies/forms.py | 10 ++++++++++ pendencies/migrations/0001_initial.py | 25 +++++++++++++++++++++++++ pendencies/migrations/0002_pendencies_resource.py | 24 ++++++++++++++++++++++++ pendencies/migrations/__init__.py | 0 pendencies/models.py | 11 +++++++++++ pendencies/tests.py | 3 +++ pendencies/views.py | 3 +++ students_group/migrations/0003_auto_20170119_1543.py | 19 +++++++++++++++++++ topics/migrations/0005_resource.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ topics/models.py | 28 ++++++++++++++++++++++++++-- topics/templates/topics/list.html | 17 +++++++++++++++++ webpage/__init__.py | 0 webpage/admin.py | 3 +++ webpage/apps.py | 5 +++++ webpage/forms.py | 24 ++++++++++++++++++++++++ webpage/migrations/0001_initial.py | 30 ++++++++++++++++++++++++++++++ webpage/migrations/__init__.py | 0 webpage/models.py | 15 +++++++++++++++ webpage/templates/webpages/_form.html | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ webpage/templates/webpages/create.html | 35 +++++++++++++++++++++++++++++++++++ webpage/tests.py | 3 +++ webpage/urls.py | 8 ++++++++ webpage/views.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 30 files changed, 775 insertions(+), 3 deletions(-) create mode 100644 amadeus/static/js/jquery.formset.js create mode 100644 pendencies/__init__.py create mode 100644 pendencies/admin.py create mode 100644 pendencies/apps.py create mode 100644 pendencies/forms.py create mode 100644 pendencies/migrations/0001_initial.py create mode 100644 pendencies/migrations/0002_pendencies_resource.py create mode 100644 pendencies/migrations/__init__.py create mode 100644 pendencies/models.py create mode 100644 pendencies/tests.py create mode 100644 pendencies/views.py create mode 100644 students_group/migrations/0003_auto_20170119_1543.py create mode 100644 topics/migrations/0005_resource.py create mode 100644 webpage/__init__.py create mode 100644 webpage/admin.py create mode 100644 webpage/apps.py create mode 100644 webpage/forms.py create mode 100644 webpage/migrations/0001_initial.py create mode 100644 webpage/migrations/__init__.py create mode 100644 webpage/models.py create mode 100644 webpage/templates/webpages/_form.html create mode 100644 webpage/templates/webpages/create.html create mode 100644 webpage/tests.py create mode 100644 webpage/urls.py create mode 100644 webpage/views.py diff --git a/amadeus/settings.py b/amadeus/settings.py index 0448ebf..1e5825c 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -60,6 +60,8 @@ INSTALLED_APPS = [ 'subjects', 'students_group', 'topics', + 'pendencies', + 'webpage', 'mailsender', 'security', 'themes' diff --git a/amadeus/static/js/jquery.formset.js b/amadeus/static/js/jquery.formset.js new file mode 100644 index 0000000..1e167fe --- /dev/null +++ b/amadeus/static/js/jquery.formset.js @@ -0,0 +1,170 @@ +/** + * jQuery Formset 1.2 + * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com) + * @requires jQuery 1.2.6 or later + * + * Copyright (c) 2009, Stanislaus Madueke + * All rights reserved. + * + * Licensed under the New BSD License + * See: http://www.opensource.org/licenses/bsd-license.php + */ +;(function($) { + $.fn.formset = function(opts) + { + var options = $.extend({}, $.fn.formset.defaults, opts), + flatExtraClasses = options.extraClasses.join(' '), + $$ = $(this), + + applyExtraClasses = function(row, ndx) { + if (options.extraClasses) { + row.removeClass(flatExtraClasses); + row.addClass(options.extraClasses[ndx % options.extraClasses.length]); + } + }, + + updateElementIndex = function(elem, prefix, ndx) { + var idRegex = new RegExp('(' + prefix + '-\\d+-)|(^)'), + replacement = prefix + '-' + ndx + '-'; + if (elem.attr("for")) elem.attr("for", elem.attr("for").replace(idRegex, replacement)); + if (elem.attr('id')) elem.attr('id', elem.attr('id').replace(idRegex, replacement)); + if (elem.attr('name')) elem.attr('name', elem.attr('name').replace(idRegex, replacement)); + }, + + hasChildElements = function(row) { + return row.find('input,select,textarea,label').length > 0; + }, + + insertDeleteLink = function(row) { + if (row.is('TR')) { + // If the forms are laid out in table rows, insert + // the remove button into the last table cell: + row.children(':last').append('' + options.deleteText + ''); + } else if (row.is('UL') || row.is('OL')) { + // If they're laid out as an ordered/unordered list, + // insert an
  • after the last list item: + row.append('
  • ' + options.deleteText +'
  • '); + } else { + // Otherwise, just insert the remove button as the + // last child element of the form's container: + row.append('' + options.deleteText +''); + } + row.find('a.' + options.deleteCssClass).click(function() { + var row = $(this).parents('.' + options.formCssClass), + del = row.find('input:hidden[id $= "-DELETE"]'); + if (del.length) { + // We're dealing with an inline formset; rather than remove + // this form from the DOM, we'll mark it as deleted and hide + // it, then let Django handle the deleting: + del.val('on'); + row.hide(); + } else { + row.remove(); + // Update the TOTAL_FORMS form count. + // Also update names and IDs for all remaining form controls so they remain in sequence: + var forms = $('.' + options.formCssClass).not('.formset-custom-template'); + $('#id_' + options.prefix + '-TOTAL_FORMS').val(forms.length); + for (var i=0, formCount=forms.length; i