Sha256: 520c8a0bfda86d9178a9f7af4802d92067dbcf1b0b6fafc0c4843c4aa09d5dce

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8
module Mutx
  module Routes
    module Admin
      module Repositories
        class Routes < App
          define do
            on post do
    
              # TO CREATE A REPO
              on root do
                Mutx::Support::Log.debug "data is => #{post_data}" #only has a repo_name
                response = Mutx::API::Repo.validate_and_create post_data # Creates a new 'repo'
                # Si success es true
                Mutx::Support::Log.debug "#{response}"
                res.redirect path_for(:admin_repositories_index)
              end

              on ':repository_id' do
                result = Mutx::API::Repo.update_repo_name(post_data["_id"], post_data["name"])
                flash[:info] = result[:message]                
                res.redirect path_for(:admin_repositories_index)
              end
            end

            on get do
              on "new" do
                res.write view('Admin Repositories New', action: 'new')
              end

              on ":repository_id/delete" do |repository_id|
                result = Mutx::API::Repo.delete_repo(repository_id)
                flash[:info] = result[:message]
                res.redirect path_for(:admin_repositories_index)
              end

              on ':repository_id/edit' do |repository_id|
                repo = Mutx::API::Repo.get_data(repository_id)
                res.write view('Admin Repositories Edit', repo: repo)
              end

              on root do
                repositories = Mutx::Database::MongoConnector.all_repos
                res.write view('Admin Repositories', repositories: repositories)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutx-0.2.9 lib/mutx/routes/admin_routes/repositories_routes.rb
mutx-0.2.8 lib/mutx/routes/admin_routes/repositories_routes.rb
mutx-0.2.7 lib/mutx/routes/admin_routes/repositories_routes.rb
mutx-0.2.6 lib/mutx/routes/admin_routes/repositories_routes.rb
mutx-0.2.5 lib/mutx/routes/admin_routes/repositories_routes.rb
mutx-0.2.4 lib/mutx/routes/admin_routes/repositories_routes.rb