<commit_before>$ = jQuery.sub()
User = App.User

class Index extends App.Controller
  className: 'container signup'
  
  events:
    'submit form': 'submit',
    'click .submit': 'submit',
    'click .cancel': 'cancel',

  constructor: ->
    super
    
    # set title
    @title 'Sign up'
    @navupdate '#signup'

    @render()
    
  render: ->
    
    # set password as required
    for item in User.configure_attributes
      if item.name is 'password'
        item.null = false

    @html App.view('signup')(
      form: @formGen( model: User, required: 'signup' ),
    )

  cancel: ->
    @navigate 'login'

  submit: (e) ->
    @log 'submit'
    e.preventDefault()
    @params = @formParam(e.target)
    ###
    for num in [1..199]
      user = new User
      params.login = 'login_c' + num
      user.updateAttributes(params)
    return false
    ###
    
    # if no login is given, use emails as fallback
    if !@params.login && @params.email
      @params.login = @params.email
      
    @params.role_ids = [0]
    @log 'updateAttributes', @params
    user = new User
    user.load(@params)

    errors = user.validate()
    if errors
      @log 'error new', errors
      @validateForm( form: e.target, errors: errors )
      return false

    # save user
    user.save(
      success: (r) =>
        auth = new App.Auth
        auth.login(
          data: {
            username: @params.login,
            password: @<PASSWORD>,
          },
          success: @success
          error: @error,
        )
#      error: =>
#        @modalHide()
    )
  <commit_msg>Code cleanup.<commit_after>$ = jQuery.sub()

class Index extends App.Controller
  className: 'container signup'
  
  events:
    'submit form': 'submit',
    'click .submit': 'submit',
    'click .cancel': 'cancel',

  constructor: ->
    super
    
    # set title
    @title 'Sign up'
    @navupdate '#signup'

    @render()
    
  render: ->
    
    # set password as required
    for item in App.User.configure_attributes
      if item.name is 'password'
        item.null = false

    @html App.view('signup')(
      form: @formGen( model: App.User, required: 'signup' ),
    )

  cancel: ->
    @navigate 'login'

  submit: (e) ->
    @log 'submit'
    e.preventDefault()
    @params = @formParam(e.target)
    ###
    for num in [1..199]
      user = new App.User
      params.login = 'login_c' + num
      user.updateAttributes(params)
    return false
    ###
    
    # if no login is given, use emails as fallback
    if !@params.login && @params.email
      @params.login = @params.email
      
    @params.role_ids = [0]
    @log 'updateAttributes', @params
    user = new App.User
    user.load(@params)

    errors = user.validate()
    if errors
      @log 'error new', errors
      @validateForm( form: e.target, errors: errors )
      return false

    # save user
    user.save(
      success: (r) =>
        auth = new App.Auth
        auth.login(
          data: {
            username: @params.login,
            password: <PASSWORD>,
          },
          success: @success
          error: @error,
        )
#      error: =>
#        @modalHide()
    )
  
{'fraction_non_alphanumeric': 0.1289914638001897, 'fraction_numerical': 0.003161555485298767, 'mean_word_length': 1.9000916590284143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5709158', 'n_tokens_mistral': 1007, 'n_tokens_neox': 990, 'n_words': 269}