forked from openstreetmap/openstreetmap-website
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Links must be https. Add validate_url ruby gem to validate the urls. Add not null on link site and url. Add relevant FK.
- Loading branch information
Showing
22 changed files
with
616 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,4 @@ | |
label { | ||
font-weight: bold; | ||
} | ||
ul { | ||
display: inline-block; | ||
} | ||
ul > li { | ||
display: inline-block; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class CommunityLinksController < ApplicationController | ||
layout "site" | ||
before_action :authorize_web | ||
|
||
before_action :set_link, :only => [:destroy, :edit, :update] | ||
|
||
load_and_authorize_resource :except => [:create, :new] | ||
authorize_resource | ||
|
||
def index | ||
@community = Community.friendly.find(params[:community_id]) | ||
@links = @community.community_links | ||
end | ||
|
||
def new | ||
return "missing parameter community_id" unless params.key?(:community_id) | ||
|
||
@community = Community.friendly.find(params[:community_id]) | ||
@title = t ".title" | ||
@link = CommunityLink.new | ||
@link.community_id = params[:community_id] | ||
end | ||
|
||
def edit; end | ||
|
||
def create | ||
@community = Community.friendly.find(params[:community_id]) | ||
@link = @community.community_links.build(link_params) | ||
if @link.save | ||
response.set_header("link_id", @link.id) # for testing | ||
redirect_to @link.community, :notice => t(".success") | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def update | ||
if @link.update(link_params) | ||
redirect_to @link.community, :notice => t(".success") | ||
else | ||
flash.now[:alert] = t(".failure") | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
community_id = @link.community_id | ||
@link.delete | ||
redirect_to community_path(community_id) | ||
end | ||
|
||
private | ||
|
||
def set_link | ||
@link = CommunityLink.find(params[:id]) | ||
end | ||
|
||
def link_params | ||
params.require(:community_link).permit(:community_id, :text, :url) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# == Schema Information | ||
# | ||
# Table name: community_links | ||
# | ||
# id :bigint(8) not null, primary key | ||
# community_id :bigint(8) not null | ||
# text :string not null | ||
# url :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_community_links_on_community_id (community_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (community_id => communities.id) | ||
# | ||
|
||
class CommunityLink < ApplicationRecord | ||
belongs_to :community | ||
validates :text, :presence => true, :length => 1..255, :characters => true | ||
validates :url, :presence => true, :length => 1..255, :url => { :schemes => ["https"] } | ||
end |
Oops, something went wrong.