travis-web/assets/scripts/app/models/hook.coffee
Henrik Hodne 2450f9fe9d Revert previous revert
I found the commit that caused the bug that caused me to do the last
revert. I'm therefore reverting the previous revert and I will be
committing a revert that reverts the commit that introduced the bug. See
next commit.

This reverts commit db2d38a7af.
2014-02-12 09:54:24 -06:00

40 lines
1.2 KiB
CoffeeScript

require 'travis/model'
@Travis.Hook = Travis.Model.extend
name: Ember.attr('string')
ownerName: Ember.attr('string')
description: Ember.attr('string')
active: Ember.attr('boolean')
admin: Ember.attr('boolean')
account: (->
@get('slug').split('/')[0]
).property('slug')
slug: (->
"#{@get('ownerName')}/#{@get('name')}"
).property('ownerName', 'name')
urlGithub: (->
"https://github.com/#{@get('slug')}"
).property()
urlGithubAdmin: (->
"https://github.com/#{@get('slug')}/settings/hooks#travis_minibucket"
).property()
toggle: ->
return if @get('isSaving')
@set 'active', !@get('active')
@save()
repo: (->
# I don't want to make an ajax request for each repository showed in profile,
# especially, because most of them does not have any builds anyway. That's why
# I add an info which we have here to the store - this will allow to display
# a link to the repo and if more info is needed, it will be requested when the
# link is used
Travis.loadOrMerge(Travis.Repo, @getProperties('id', 'slug', 'name', 'ownerName'), skipIfExists: true)
Travis.Repo.find(@get('id'))
).property('id')