<commit_before>AuthenticatedRoute = require './authenticated'
Project = require '../models/project'
Translation = require '../models/translation'

App.ProjectRoute = AuthenticatedRoute.extend
  beforeModel: ->
    @loadingIndicator = new Spinner().spin()
    document.querySelector('#app').appendChild @loadingIndicator.el
    
  afterModel: ->
    @loadingIndicator.stop()

  model: (params) ->
    promises = Ember.RSVP.hash
      project: zooniverse.api.get("/projects/#{ params.name }", with_roles: true)
      translation: zooniverse.api.get("/projects/#{ params.name }/translations")
    
    promises.then (resolved) ->
      project = Project.create resolved.project
      project.set 'translation', Translation.create(resolved.translation)
      project
  
  setupController: (controller, project) ->
    controller.set 'model', project
    currentLocale = controller.get 'currentLocale'
    selectedType = controller.getWithDefault 'selectedType', 'todo'
    
    controller.set 'selectedType', selectedType
    controller.set 'model.translation.currentLocale', currentLocale
    controller.set 'model.translation.selectedType', selectedType<commit_msg>Ensure AuthenticatedRoute method is called.  Should close #7<commit_after>AuthenticatedRoute = require './authenticated'
Project = require '../models/project'
Translation = require '../models/translation'

App.ProjectRoute = AuthenticatedRoute.extend
  beforeModel: ->
    @_super arguments...
    if zooniverse.models.User.current
      @loadingIndicator = new Spinner().spin()
      document.querySelector('#app').appendChild @loadingIndicator.el
  
  afterModel: ->
    @loadingIndicator.stop()
  
  model: (params) ->
    promises = Ember.RSVP.hash
      project: zooniverse.api.get("/projects/#{ params.name }", with_roles: true)
      translation: zooniverse.api.get("/projects/#{ params.name }/translations")
    
    promises.then (resolved) ->
      project = Project.create resolved.project
      project.set 'translation', Translation.create(resolved.translation)
      project
  
  setupController: (controller, project) ->
    controller.set 'model', project
    currentLocale = controller.get 'currentLocale'
    selectedType = controller.getWithDefault 'selectedType', 'todo'
    
    controller.set 'selectedType', selectedType
    controller.set 'model.translation.currentLocale', currentLocale
    controller.set 'model.translation.selectedType', selectedType
{'fraction_non_alphanumeric': 0.11926229508196722, 'fraction_numerical': 0.0004098360655737705, 'mean_word_length': 3.9613821138211383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '324825', 'n_tokens_mistral': 643, 'n_tokens_neox': 650, 'n_words': 136}