<commit_before>;
(function(ns) {
    ns.User = chorus.models.Base.extend({
        urlTemplate : "user/{{id}}",
        showUrlTemplate : "users/{{id}}",

        workspaces: function() {
            if (!this._workspaces) {
                this._workspaces = new ns.WorkspaceSet();
                this._workspaces.urlTemplate = "workspace/?user=" + this.get("id");
                this._workspaces.bind("reset", function() {
                    this.trigger("change");
                }, this);
            }
            return this._workspaces;
        },

        declareValidations : function(newAttrs) {
            this.require('firstName', newAttrs);
            this.require('lastName', newAttrs);
            this.require('userName', newAttrs);
            this.requirePattern('emailAddress', /[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+/, newAttrs);
            if(this.isNew() || (newAttrs && newAttrs.hasOwnProperty("password"))) {
                this.require("password", newAttrs);
                this.requireConfirmation('password', newAttrs);
            }
        },

        hasImage: function() {
            return true;
        },

        imageUrl : function(options){
            options = (options || {});
            return "/edc/userimage/" + this.get("userName") + "?size=" + (options.size || "original");
        },

        picklistImageUrl : function(){
            return this.imageUrl();
        },

        savePassword : function(attrs){
            var passwordUrl = this.url() + "/password";
            this.save(attrs, { url : passwordUrl });
        },

        displayName : function() {
            return [this.get("firstName"), this.get("lastName")].join(' ');
        },

        attrToLabel : {
            "emailAddress" : "users.email",
            "firstName" : "users.first_name",
            "lastName" : "users.last_name",
            "userName" : "users.username",
            "password" : "<PASSWORD>",
            "title" : "users.title",
            "department" : "users.department",
            "admin" : "users.administrator"
        }
    });
})(chorus.models);
<commit_msg>in User, extract separate methods for validating email addresses and confirmation on change<commit_after>;
(function(ns) {
    ns.User = chorus.models.Base.extend({
        urlTemplate : "user/{{id}}",
        showUrlTemplate : "users/{{id}}",

        workspaces: function() {
            if (!this._workspaces) {
                this._workspaces = new ns.WorkspaceSet();
                this._workspaces.urlTemplate = "workspace/?user=" + this.get("id");
                this._workspaces.bind("reset", function() {
                    this.trigger("change");
                }, this);
            }
            return this._workspaces;
        },

        declareValidations : function(newAttrs) {
            this.require('firstName', newAttrs);
            this.require('lastName', newAttrs);
            this.require('userName', newAttrs);
            this.requireValidEmailAddress('emailAddress', newAttrs);
            this.requireConfirmationForChange('password', newAttrs);
        },

        requireValidEmailAddress: function(name, newAttrs) {
            this.requirePattern(name, /[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+/, newAttrs);
        },

        requireConfirmationForChange: function(name, newAttrs) {
            if(this.isNew() || (newAttrs && newAttrs.hasOwnProperty(name))) {
                this.require(name, newAttrs);
                this.requireConfirmation(name, newAttrs);
            }
        },

        hasImage: function() {
            return true;
        },

        imageUrl : function(options){
            options = (options || {});
            return "/edc/userimage/" + this.get("userName") + "?size=" + (options.size || "original");
        },

        picklistImageUrl : function(){
            return this.imageUrl();
        },

        savePassword : function(attrs){
            var passwordUrl = this.url() + "/password";
            this.save(attrs, { url : passwordUrl });
        },

        displayName : function() {
            return [this.get("firstName"), this.get("lastName")].join(' ');
        },

        attrToLabel : {
            "emailAddress" : "users.email",
            "firstName" : "users.first_name",
            "lastName" : "users.last_name",
            "userName" : "users.username",
            "password" : "<PASSWORD>",
            "title" : "users.title",
            "department" : "users.department",
            "admin" : "users.administrator"
        }
    });
})(chorus.models);

{'fraction_non_alphanumeric': 0.16166231505657094, 'fraction_numerical': 0.0, 'mean_word_length': 1.818516247700797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427220', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1253, 'n_words': 206}