certificate_invalidation.js 1.13 KB
Newer Older
1
// Backbone.js Application Model: CertificateInvalidation
2
/* global define, RequireJS */
3

4
(function(define) {
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    'use strict';

    define(
        ['underscore', 'underscore.string', 'gettext', 'backbone'],

        function(_, str, gettext, Backbone) {
            return Backbone.Model.extend({
                idAttribute: 'id',

                defaults: {
                    user: '',
                    invalidated_by: '',
                    created: '',
                    notes: ''
                },

21
                initialize: function(attributes, options) {
22
                    this.url = options.url;
23 24 25
                },

                validate: function(attrs) {
26
                    if (!str.trim(attrs.user)) {
27 28 29 30 31 32 33 34
                        // A username or email must be provided for certificate invalidation
                        return gettext('Student username/email field is required and can not be empty. ' +
                            'Kindly fill in username/email and then press "Invalidate Certificate" button.');
                    }
                }
            });
        }
    );
35
}).call(this, define || RequireJS.define);