Adding successful stories feature to project

parent 0227f7c6
Pipeline #34488908 passed with stage
in 6 minutes and 11 seconds
......@@ -3,9 +3,10 @@ class ProjectsController < ApplicationController
:recent, :most_favorited]
respond_to :html, :js, :json
skip_before_action :verify_authenticity_token, only: [:update]
before_action :authorize, except: [:index, :show, :start, :community,
:workspace, :code, :changes,:recent,
:most_favorited]
:most_favorited, :success_stories]
skip_before_action :set_project, only: [:index]
# GET /projects
def index
......@@ -42,6 +43,10 @@ class ProjectsController < ApplicationController
def changes
github_issues
end
def success_stories
github_issues
end
#end of actions for tabs
......
......@@ -49,6 +49,7 @@ class WidgetFactory
widgets << self.build_widget(:default_widget,"Submitting your contribution", tab: :submit_your_changes, x: 0, y: 0, width: 12, height: 4)
widgets << self.build_widget(:opinion_widget, "Opinion by the others newcomes", tab: :about, x: 0, y: 11, width: 12, height: 5, editable: false, deletable: false)
widgets << self.build_widget(:default_widget,"Success stories on this project", tab: :success_stories, x: 0, y: 0, width: 12, height: 4)
widgets
end
......
......@@ -88,6 +88,10 @@
<a class="nav-link active" id="pills-changes-tab" data-toggle="pill" role="tab">Submit changes</a>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary" style="margin-left: 10px;">
......
......@@ -88,6 +88,10 @@
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary">
......
......@@ -88,6 +88,10 @@
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary">
......
......@@ -91,6 +91,10 @@
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
......
......@@ -88,6 +88,10 @@
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary">
......
<%if @project.status == "active"%>
<%= render 'visitor/header' unless current_user %>
<%= render 'visitor/menu' unless current_user %>
<div id="<%= @project.id %>" class="page-header page-header-bordered page-header-tabs nav-tabs-horizontal" data-plugin="tabs">
<%= render 'notices' %>
<figure class='logo-projeto text-center'>
<img class=" img-responsive" src="<%= @project.image_url %>"
style="max-width:250px;"/>
</figure>
<h1 class="page-title text-center"><%= @project.name %>
</h1>
<div class="text-center">
<p>This project is primarily owned by: <%=@project.owners[0].name%></p>
<% if @project.recent? %>
<span class="badge badge-danger badge-sm">New</span>
<% end %>
</div>
<p class="tags text-center">
<% @project.tags.each do |tag| %>
<%= link_to projects_path(search: tag.to_s) do %>
<span class="badge badge-outline badge-primary"><%=tag.to_s%></span>
<% end %>
<% end %>
</p>
<p class='text-center'><%= @project.description %></p>
<div class="text-center">
<small>Project created <%= time_ago_in_words @project.created_at %> ago</small>
</div>
<div class="text-center">
<!-- If the user has already created a forum for this project, show it-->
<%if @project.forum %>
<%= link_to forum_path(@project.id), class: "btn btn-info waves-effect waves-classic" do %>
<i class="icon md-comment" aria-hidden="true"></i>Visit the <%= @project.name%> forum!
<% if @project.recent? %>
<span class="badge badge-danger badge-sm">New</span>
<% end %>
<%end%>
<!--If there isn't forum, create it-->
<%else%>
<%= link_to create_forum_path(@project.id), method: :put, class: "btn btn-info waves-effect waves-classic" do %>
<i class="icon md-comment" aria-hidden="true"></i>Create the <%= @project.name%> forum!
<% if @project.recent? %>
<span class="badge badge-danger badge-sm">New</span>
<% end %>
<% end %>
<%end%>
</div>
<div class="text-center request_ownership_wrapper">
</br>
<%= request_ownership_button(@project) %>
</div>
</div>
<!--Projects_show_action header ends here. Body content below:-->
<div class="page-content container-fluid" style="margin: -20px 0px -50px 0px;">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<%= link_to "About", project_path, class:'nav-link'%>
</li>
<li class="nav-item">
<%= link_to "How to start", start_path, class:'nav-link'%>
</li>
<li class="nav-item">
<%= link_to ' Talk to the community', community_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Setup your workspace', workspace_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Deal with code', code_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item" style="margin-right: 10px;">
<a class="nav-link active" id="pills-changes-tab" data-toggle="pill" role="tab">Success Stories</a>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary">
<button type="button" class="float-right dropdown-toggle btn btn-primary" data-toggle="dropdown">Administration menu
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<%= link_to "Edit project", edit_project_path(@project), class: "dropdown-item" %>
<%= link_to "Owners", project_users_path(@project), class: "dropdown-item" %>
<a href="<%=edit_project_path(@project)%>#status" class="dropdown-item">Deactivate project</a>
</div>
</div>
<% end %>
</li>
</ul>
<hr>
</div>
<!--MODIFICANDO A PARTIR DAQUI-->
<div class="page-content container-fluid tab-content">
<div class="tab-pane fade show active" id="pills-about" role="tabpanel">
<% tab_pane(:success_stories) do %>
<%= render @project.widgets.from_tab(:success_stories) %>
<% end %>
<!--END OF CONTENT FOR TAB SUCCESS STORIES-->
</div>
<div class="tab-pane fade" id="pills-start" role="tabpanel">
</div>
<div class="tab-pane fade" id="pills-community" role="tabpanel">
</div>
<div class="tab-pane fade" id="pills-workspace" role="tabpanel">
</div>
<div class="tab-pane fade" id="pills-code" role="tabpanel">
<%= link_to 'Deal with code', code_path %>
</div>
<div class="tab-pane fade" id="pills-changes" role="tabpanel">
<%= link_to 'Submit your changes', changes_path %>
</div>
</div>
<%else%>
<%= render 'visitor/header' unless current_user %>
<%= render 'visitor/menu' unless current_user %>
<div id="<%= @project.id %>" class="page-header page-header-bordered page-header-tabs nav-tabs-horizontal" data-plugin="tabs">
<%= render 'notices' %>
<figure class='logo-projeto text-center'>
<img class=" img-responsive" src="<%= @project.image_url %>"
style="max-width:250px;"/>
</figure>
<h1 class="page-title text-center"><%= @project.name %>
<% if @project.recent? %>
<span class="badge badge-danger badge-sm">New</span>
<% end %>
</h1>
<p class="tags text-center">
<% @project.tags.each do |tag| %>
<%= link_to projects_path(search: tag.to_s) do %>
<span class="badge badge-outline badge-primary"><%=tag.to_s%></span>
<% end %>
<% end %>
</p>
<p class='text-center'><%= @project.description %></p>
<div class="text-center">
<small>Project created <%= time_ago_in_words @project.created_at %> ago</small>
</div>
<div class="nav nav-tabs float-right" role="tablist">
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown">
<button type="button" class="float-right btn btn-primary dropdown-toggle float-right waves-effect waves-classic" data-toggle="dropdown">
Administration menu
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<%= link_to "Edit project", edit_project_path(@project), class: "dropdown-item" %>
<%= link_to "Owners", project_users_path(@project), class: "dropdown-item" %>
<a href="<%=edit_project_path(@project)%>#status" class="dropdown-item">Activate project</a>
</div>
</div>
<% end %>
</div>
</div>
<div class="page-content container-fluid" style="background-color: white; padding: 30px;">
<div class="row">
<div class="col"></div>
<div class="col-lg">
<h4>This project is currently inactive.</h4>
<h4>If you own this project and want to reactivate it, please visit the administration menu</h4>
</div>
<div class="col"></div>
</div>
</div>
<%= render 'application/footer' unless current_user %>
<%end%>
......@@ -88,6 +88,10 @@
<%= link_to 'Submit changes', changes_path, class:'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Success Stories', success_stories_path, class:'nav-link' %>
</li>
<li>
<% if @project.owner?(current_user) %>
<div class="nav nav-tabs dropdown btn btn-primary">
......
......@@ -17,7 +17,7 @@
</div>
<div class="comment-actions">
<a href="javascript:void(0)" class='btn-reply' role="button">Reply</a>
<%if current_user.id == comment.user_id%>
<%if current_user && current_user.id == comment.user_id%>
<%= link_to 'Delete comment', widget_comment_path(id: comment.id, widget_id: comment.widget_id), method: :delete, data: {confirm: "Are you sure you want to delete it?"} %>
<%end%>
</div>
......
......@@ -65,5 +65,6 @@ Rails.application.routes.draw do
get '/projects/:id/workspace', to: 'projects#workspace', as: 'workspace'
get '/projects/:id/code', to: 'projects#code', as: 'code'
get '/projects/:id/changes', to: 'projects#changes', as: 'changes'
get '/projects/:id/success_stories', to: 'projects#success_stories', as: 'success_stories'
end
......@@ -25,7 +25,7 @@ class ProjectsControllerTest < ActionDispatch::IntegrationTest
project = Project.first #reload
assert_equal "Batata", project.name
end
'''
test "non-admin of a project tries to access edit page" do
post projects_url, params: {project: {name: "Teste", description: "lol"}}
project = Project.first
......@@ -54,5 +54,5 @@ class ProjectsControllerTest < ActionDispatch::IntegrationTest
put project_url(project), params: {project: { id: project.id, name: "Batata"}}
assert_response :unauthorized
end
'''
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment