diff --git a/app/assets/javascripts/cafe_works.js.coffee b/app/assets/javascripts/cafe_works.js.coffee index 1486edb13..6a6d1b996 100644 --- a/app/assets/javascripts/cafe_works.js.coffee +++ b/app/assets/javascripts/cafe_works.js.coffee @@ -1,5 +1,6 @@ jQuery -> - $('.datetimepicker').datetimepicker locale: 'sv', format: 'DD/MM/YYYY HH:mm' + $('.datetimepicker').datetimepicker + format: 'DD/MM/YYYY HH:mm' jQuery -> $('#date').datepicker() jQuery -> diff --git a/app/assets/javascripts/rents.js.coffee b/app/assets/javascripts/rents.js.coffee index 7d596747a..cdb2372ae 100644 --- a/app/assets/javascripts/rents.js.coffee +++ b/app/assets/javascripts/rents.js.coffee @@ -1,3 +1,8 @@ +jQuery -> + $('.datetimepicker1').datetimepicker + format: 'DD/MM/YYYY HH:mm' + $('.datetimepicker2').datetimepicker + format: 'DD/MM/YYYY HH:mm' loadCalendar = -> $('#bilkalender').fullCalendar events: '/bil', @@ -35,4 +40,4 @@ $('document').ready -> else $('.after_disclaimer').hide() if $('#rent_disclaimer').is(':checked') - $('.after_disclaimer').show() \ No newline at end of file + $('.after_disclaimer').show() diff --git a/app/controllers/admin/rents_controller.rb b/app/controllers/admin/rents_controller.rb index 07ad8a57a..80eefdb51 100644 --- a/app/controllers/admin/rents_controller.rb +++ b/app/controllers/admin/rents_controller.rb @@ -1,6 +1,5 @@ class Admin::RentsController < ApplicationController load_permissions_and_authorize_resource - before_action :set_rent, only: [:show, :update, :destroy, :preview] before_action :set_councils, only: [:new, :show] def main @@ -18,11 +17,10 @@ def preview def create @rent = Rent.new_with_status(rent_params, nil) flash[:notice] = 'Bokningen skapades' if @rent.save(validate: false) - respond_with @rent + redirect_to @rent end def new - @rent = Rent.new end def update @@ -37,22 +35,6 @@ def destroy private - def authenticate - flash[:error] = t('the_role.access_denied') - redirect_to(:back) unless (current_user) && (current_user.moderator?(:bil)) - rescue ActionController::RedirectBackError - redirect_to root_path - end - - # Makes sure that a rent is found, otherwise redirects to admin page - def set_rent - @rent = Rent.find_by_id(params[:id]) - if (@rent == nil) - flash[:notice] = 'Hittade ingen bilbokning med det ID:t.' - redirect_to(:admin_car) - end - end - # To set the councils def set_councils @councils = Council.all diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index ff572adef..4d1fca6c2 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -1,214 +1,88 @@ # encoding:UTF-8 class AlbumsController < ApplicationController load_permissions_and_authorize_resource + load_and_authorize_resource :image, through: :album before_action :set_edit - before_action :set_album, except: [:index,:new,:create,:settings] before_action :categories - + def index @albums = Album.order('start_date asc') - @albums_latest = Album.order('created_at desc LIMIT 4') - - if (params[:id] != nil) && (params[:datum] != "") - @id = params[:id] - @datum = Date.parse(params[:datum]) - if @datum < Date.today - if @kategorier.find_by_id(@id) - @searched = Album.where(:start_date => @datum..Date.today).all - else - @searched = Album.where(:category => @kategorier.find(@id).name, :start_date => @datum...Date.today).all - end - end - elsif (params[:id]) && (params[:datum] == "" ) - @id = params[:id] - @searched = Album.where(:category => @kategorier.find(@id).name) - end - + @albums_latest = Album.order('created_at desc LIMIT 4') end - + def edit - if(params[:commit]) && (current_user) && (current_user.moderator?(:galleri)) - if(params[:commit] == 'Markera alla') - @mark = true - elsif(params[:commit] == 'Ta bort markerade') && (params[:image_ids]) - params[:image_ids].each { |img_id| - img = Image.find_by_id(img_id) - if(img) - img.destroy - end - } - flash.now[:notice] = 'De markerade bilderna togs bort.' - elsif(params[:commit] == 'Byt kategori') && (params[:image_ids]) && (params[:image_category]) - params[:image_ids].each { |img_id| - img = Image.find_by_id(img_id) - if(img) - img.subcategory_id = params[:image_category] - img.save() - end - } - flash.now[:notice] = 'De markerade bilderna har nu kategorin: '+Subcategory.find_by_id(params[:image_category]).text - end - end - - end - - def settings - unless @kategori - @kategori = AlbumCategory.new - end - unless @kategorier - @kategorier = AlbumCategory.order('name desc') - end - - if (params[:commit] == "Spara ny kategori") && (params[:album_category][:name] != nil) - @kategori.update(name: params[:album_category][:name],text: params[:album_category][:text],visible: params[:album_category][:visible]) - if @kategori.save - flash.now[:notice] = 'Kategorin '+@kategori.name+' skapades till Bildgalleriet' - @kategorier = AlbumCategory.order('name desc') - @kategori = AlbumCategory.new - end - end - - if (params[:commit] == 'Spara kategori') && (params[:album_category][:id].nil? == false) - @kategorin = AlbumCategory.find(params[:album_category][:id]) - @kategorin.update(name: params[:album_category][:name],text: params[:album_category][:text],visible: params[:album_category][:visible]) - if @kategorin.save - @kategorier = AlbumCategory.unscoped.order('name desc') - flash.now[:notice] = 'Kategorin '+@kategorin.name+' uppdaterades till Bildgalleriet' - end - end - - if (params[:commit] == 'Ta bort kategori')&&(params[:album_category]) - @category = AlbumCategory.find_by_id(params[:album_category][:id]).destroy - @kategorier = AlbumCategory.all - flash.now[:notice] = 'Kategorin togs bort' - end - - unless @subcategory - @subcategory = Subcategory.new - end - unless @subcategories - @subcategories = Subcategory.order('text desc') - end - - if (params[:commit] == "Spara ny underkategori") && (params[:subcategory][:text] != nil) - @subcategory.update(text: params[:subcategory][:text]) - if @subcategory.save - flash.now[:notice] = 'Underkategorin '+@subcategory.text+' skapades till Bildgalleriet' - @subcategory = Subcategory.new() - - end - end - - if (params[:commit] == 'Spara underkategori') && (params[:subcategory][:id].nil? == false) - @subcategory = Subcategory.find(params[:subcategory][:id].nil? == false) - @subcategory.update(text: params[:subcategory][:text]) - if @subcategory.save - @subcategories = Subcategory.unscoped.order('text desc') - flash.now[:notice] = 'Underkategorin '+@subcategory.text+' uppdaterades till Bildgalleriet' - end - end - - if (params[:commit] == 'Ta bort underkategori')&&(params[:subcategory][:id].nil? == false) - @category = Subcategory.find(params[:subcategory][:id]).destroy - @subcategories = Subcategory.unscoped.order('text desc') - flash.now[:notice] = 'Kategorin togs bort' - end - end - - def show + + # TODO add Settings somewhere else + + def show if (@album.images) @images = @album.images.order('foto_file_name asc') else - @images = nil - end + @images = nil + end end - + def new - @album = Album.new end - + def create - @album = Album.new(album_params) - @album.update(author: current_user.profile) - respond_to do |format| - if @album.save - format.html { redirect_to @album, notice: 'Albumet skapades!' } - format.json { render :json => @album, :status => :created, :location => @album } - else - format.html { render action: "new" } - format.json { render json: @album.errors, status: :unprocessable_entity } - end - end + @album.author = current_user.profile + if @album.save + redirect_to @album, notice: 'Albumet skapades!' + else + render action: :new + end end - - def destroy + + def destroy @album.destroy - respond_to do |format| - format.html { redirect_to albums_url,notice: 'Albumet raderades.' } - format.json { head :no_content } - end + redirect_to albums_url, notice: 'Albumet raderades.' end + def destroy_images for image in @album.images image.destroy end - respond_to do |format| - format.html { redirect_to @album, notice: 'Bilderna tog borts!' } - format.json { render :json => @album, :location => @album } - end + redirect_to @album, notice: 'Bilderna tog borts!' end + def upload_images if (params[:fotos]) && (params[:subcategory_id]) - #===== The magic is here ;) - @count = 1 - @total = params[:fotos].count - params[:fotos].each { |foto| - flash[:notice] =("Laddar upp "+@count.to_s+"/"+@total.to_s) - @album.images.create(foto: foto,subcategory_id: params[:subcategory_id]) - @count = @count+1; - } - flash[:notice] =("Färdig! Laddat upp "+@total.to_s+" bilder.") - end + #===== The magic is here ;) + @count = 1 + @total = params[:fotos].count + params[:fotos].each do |foto| + flash[:notice] = %(Laddar upp #{@count}/#{@total}) + @album.images.create(foto: foto, subcategory_id: params[:subcategory_id]) + @count = @count + 1 + end + flash[:notice] = %(Färdig! Laddat upp #{@total} bilder.) + end end + def update - respond_to do |format| - if @album.update_attributes(album_params) - format.html { redirect_to edit_album_path(@album), :notice => 'Albumet uppdaterades!' } - format.json { head :no_content } - else - format.html { render :action => "edit" } - format.json { render :json => @album.errors, :status => :unprocessable_entity } - end + if @album.update(album_params) + redirect_to edit_album_path(@album), notice: 'Albumet uppdaterades!' + else + render action: :edit end - end -private - def authenticate - - redirect_to(:back) unless (current_user) && (current_user.moderator?(:galleri)) - - rescue ActionController::RedirectBackError - redirect_to root_path end + + private + def categories - @kategorier = AlbumCategory.order('name desc') - @subcategories = Subcategory.order('text desc') - end - def set_album - @album = Album.find(params[:id]) + @kategorier = AlbumCategory.order('name desc') + @subcategories = Subcategory.order('text desc') end + def set_edit - if (current_user) && (current_user.moderator?(:galleri)) - @edit = true - else - @edit = false - end - end - def image_params - params.fetch(:image,{}).permit(:album_id,:subcategory_id) + @edit = can? :manage, Album end + def album_params - params.fetch(:album,{}).permit(:title,:description,:author,:location,:public,:start_date,:end_date,:album_category_ids => [],:subcategory_ids => [],images_parameters: [:id, :foto]) + params.require(:album).permit(:title, :description, :author, :location, + :public, :start_date, :end_date, album_category_ids: [], + subcategory_ids: [], images_parameters: [:id, :foto]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b06929fd4..9b443552b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,8 +6,11 @@ class ApplicationController < ActionController::Base before_action :set_locale rescue_from CanCan::AccessDenied do |ex| - flash[:error] = ex.message - render text: '', layout: true, status: :forbidden + if current_user.nil? + redirect_to :new_user_session, alert: ex.message + else + redirect_to :root, alert: ex.message + end end rescue_from ActiveRecord::RecordInvalid do |ex| diff --git a/app/controllers/councils_controller.rb b/app/controllers/councils_controller.rb index bcd4da06b..cf645ca1f 100644 --- a/app/controllers/councils_controller.rb +++ b/app/controllers/councils_controller.rb @@ -1,19 +1,14 @@ # encoding:UTF-8 class CouncilsController < ApplicationController load_permissions_and_authorize_resource find_by: :url - before_action :set_page, only: :show + load_and_authorize_resource :post, through: :council + before_action :set_page, only: [:show, :edit] before_action :set_councils def index end def show - if @page - @mainelements = @page.page_elements.where(visible: true, - sidebar: false).order(:displayIndex, :asc) - @sidebarelements = @page.page_elements.where(visible: true, - sidebar: true).order(:displayIndex, :asc) - end @poster = @council.posts end @@ -26,7 +21,6 @@ def edit def create if @council.save - @council.build_page!(council_id: @council.id) redirect_to edit_council_path(@council), notice: 'Utskott skapades, success.' else render action: 'new' diff --git a/app/controllers/election/candidates_controller.rb b/app/controllers/elections/candidates_controller.rb similarity index 74% rename from app/controllers/election/candidates_controller.rb rename to app/controllers/elections/candidates_controller.rb index 296955afc..f14310a19 100644 --- a/app/controllers/election/candidates_controller.rb +++ b/app/controllers/elections/candidates_controller.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -class Election::CandidatesController < ApplicationController +class Elections::CandidatesController < ApplicationController before_action :set_election load_permissions_and_authorize_resource respond_to :html @@ -25,7 +25,7 @@ def create @candidate.profile = current_user.profile if @candidate.save flash[:notice] = 'Kandidaturen skapades.' - redirect_to [:election, @candidate] + redirect_to @candidate else render action: :new end @@ -34,7 +34,7 @@ def create def update if @candidate.update(candidate_params) flash[:notice] = 'Kandidaturen uppdaterades' - redirect_to [:election, @candidate] + redirect_to @candidate else render action: :show end @@ -43,17 +43,10 @@ def update def destroy @candidate.destroy flash[:notice] = 'Kandidaturen raderades' - redirect_to election_candidates_path + redirect_to candidates_path end private - def set_candidate - @candidate = Candidate.find_by_id(params[:id]) - if !@candidate.owner?(current_user) - flash[:error] = 'Du har inte rättigheter för att se kandidaturen.' - redirect_to(elections_path) - end - end def set_election @election = Election.current diff --git a/app/controllers/election/nominations_controller.rb b/app/controllers/elections/nominations_controller.rb similarity index 90% rename from app/controllers/election/nominations_controller.rb rename to app/controllers/elections/nominations_controller.rb index 2b47dbc23..397640f8c 100644 --- a/app/controllers/election/nominations_controller.rb +++ b/app/controllers/elections/nominations_controller.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -class Election::NominationsController < ApplicationController +class Elections::NominationsController < ApplicationController before_action :set_election load_permissions_and_authorize_resource diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index ed2787f71..fc6c47180 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -1,10 +1,7 @@ # encoding:UTF-8 class FaqsController < ApplicationController - - before_action :authenticate_editor, only: [:edit, :update, :destroy] + load_permissions_and_authorize_resource before_action :set_editor, only: [:new, :show, :edit, :index] - before_action :set_faq, only: [:show, :edit, :update, :destroy] - def index @faq = Faq.where.not(answer: '').where(category: 'main') @@ -17,7 +14,6 @@ def show end def new - @faq = Faq.new if params[:category].present? @faq.category = params[:category] end @@ -27,63 +23,36 @@ def edit end def destroy - @faq.destroy() - respond_to do |format| - format.html { redirect_to :faqs } - format.json { head :no_content } - end + @faq.destroy + redirect_to :faqs end def update - respond_to do |format| - if @faq.update(faq_params) - format.html { redirect_to @faq, notice: 'FAQ uppdaterades!' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @faq.errors, status: :unprocessable_entity } - end + if @faq.update(faq_params) + redirect_to @faq, notice: 'FAQ uppdaterades!' + else + render action: 'edit' end end def create - @faq = Faq.new(faq_params) - if @faq.answer == nil + if @faq.answer.nil? @faq.answer = '' end - respond_to do |format| - if @faq.save - format.html { redirect_to @faq, notice: 'Frågan skapades!' } - format.json { render action: 'show', status: :created, location: @faq } - else - format.html { render action: 'new' } - format.json { render json: @faq.errors, status: :unprocessable_entity } - end + if @faq.save + redirect_to @faq, notice: 'Frågan skapades!' + else + render action: 'new' end end private - def set_faq - @faq = Faq.find(params[:id]) - end - - def authenticate_editor - if !(current_user) || !(current_user.moderator?(:faq)) - flash[:error] = "Funkar inte" - redirect_to :faq - end - end def set_editor - if (current_user) && (current_user.moderator?(:faq)) - @editor = true - else - @editor = false - end + @editor = can? :manage, Faq end def faq_params params.require(:faq).permit(:question, :answer, :category) end - end diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index f9b4f8754..b748aedec 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -1,92 +1,59 @@ class NoticesController < ApplicationController - before_action :authenticate, except: [:image] - before_action :set_notice, only: [:show, :edit, :update, :destroy,:hide,:display,:image] + load_permissions_and_authorize_resource def index - @notices = Notice.all @notice_grid = initialize_grid(@notices) end def show - end def new - @notice = Notice.new end def edit - end def create - @notice = Notice.new(notice_params) - respond_to do |format| - if @notice.save - format.html { redirect_to @notice, notice: %(#{t(:notice)} #{t(:success_create)}.)} - format.json { render action: 'show', status: :created, location: @notice } - else - format.html { render action: 'new' } - format.json { render json: @notice.errors, status: :unprocessable_entity } - end + if @notice.save + redirect_to @notice, notice: %(#{t(:notice)} #{t(:success_create)}.) + else + render action: :new end end def update - respond_to do |format| - if @notice.update(notice_params) - format.html { redirect_to @notice, notice: %(#{t(:notice)} #{t(:success_update)}.) } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @notice.errors, status: :unprocessable_entity } - end + if @notice.update(notice_params) + redirect_to @notice, notice: %(#{t(:notice)} #{t(:success_update)}.) + else + render action: :edit end end def destroy @notice.destroy - respond_to do |format| - format.html { redirect_to notices_url } - format.json { head :no_content } - end - end - - # Requested to hide the current Notice - # /d.wessman - def hide - @notice.display(false) - end - - # Requested to display the current Notice - # /d.wessman - def display - @notice.display(true) + redirect_to notices_url end - # Action to show profile picture only already authenticated def image if @notice.image? - if(params[:style] == "original" || params[:style] == "large" || params[:style] == "small") - send_file(@notice.image.path(params[:style]), filename:@notice.image_file_name, type: "image/jpg",disposition: 'inline',x_sendfile: true) + if params[:style] == 'original' || params[:style] == 'large' || params[:style] == 'small' + send_file(@notice.image.path(params[:style]), + filename: @notice.image_file_name, type: 'image/jpg', + disposition: 'inline', x_sendfile: true) else - send_file(@notice.image.path(:large), filename:@notice.image_file_name, type: "image/jpg",disposition: 'inline',x_sendfile: true) + send_file(@notice.image.path(:large), + filename: @notice.image_file_name, type: 'image/jpg', + disposition: 'inline', x_sendfile: true) end end end private - def authenticate - redirect_to root_path unless current_user && (current_user.moderator?(:notiser)) - end - # Use callbacks to share common setup or constraints between actions. - def set_notice - @notice = Notice.find_by_id(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def notice_params - params.require(:notice).permit(:title, :description, :public, :d_publish, :d_remove, :sort,:image) - end + def notice_params + params.require(:notice).permit(:title, :description, + :public, :d_publish, :d_remove, + :sort, :image) + end end diff --git a/app/controllers/old_gallery_controller.rb b/app/controllers/old_gallery_controller.rb index 303d52624..d1723cad3 100644 --- a/app/controllers/old_gallery_controller.rb +++ b/app/controllers/old_gallery_controller.rb @@ -1,5 +1,5 @@ class OldGalleryController < ApplicationController - authorize_resource :class => false + authorize_resource class: false def index end end diff --git a/app/controllers/page_elements_controller.rb b/app/controllers/page_elements_controller.rb index c2362485f..844a0ff11 100644 --- a/app/controllers/page_elements_controller.rb +++ b/app/controllers/page_elements_controller.rb @@ -1,92 +1,49 @@ # encoding:UTF-8 class PageElementsController < ApplicationController - before_action :set_page_element, only: [:show, :edit, :update, :destroy] - before_action :set_council + before_action :load_permissions + load_and_authorize_resource :page, parent: true, find_by: :url + load_and_authorize_resource :page_element, through: :page - # GET /page_elements - # GET /page_elements.json def index - @page_elements = @page.page_elements - if (@page) - @mainelements = @page.page_elements.where(visible: true,sidebar: false) - @sidebarelements = @page.page_elements.where(visible:true,sidebar: true) - end - if(@mainelemnents) && (@mainelements.count > 1) - @mainelements = @mainelements.sort_by{ |x| x[:displayIndex]} - end - @poster = @council.posts - @rest = @page.page_elements.where(visible: false) end - # GET /page_elements/1 - # GET /page_elements/1.json def show end - # GET /page_elements/new def new - @page_element = PageElement.new() - @path = council_page_page_elements_path(@council) end - # GET /page_elements/1/edit def edit - - @path = council_page_page_element_path(@council,@page_element) end - # POST /page_elements - # POST /page_elements.json def create - @page_element = @page.page_elements.build(page_element_params) - - respond_to do |format| - if @page_element.save - format.html { redirect_to council_page_page_elements_path(@council), notice: 'Elementet skapades.' } - format.json { render action: 'show', status: :created, location: @page_element } - else - format.html { render action: 'new' } - format.json { render json: @page_element.errors, status: :unprocessable_entity } - end + if @page_element.save + redirect_to edit_page_page_element_path(@page, @page_element), + notice: 'Elementet skapades' + else + render action: :new end end - # PATCH/PUT /page_elements/1 - # PATCH/PUT /page_elements/1.json def update - respond_to do |format| - if @page_element.update(page_element_params) - format.html { redirect_to council_page_page_elements_path(@council), notice: 'Elementet uppdaterades.' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @page_element.errors, status: :unprocessable_entity } - end + if @page_element.update(page_element_params) + redirect_to edit_page_page_element_path(@page, @page_element), + notice: 'Elementet uppdaterades.' + else + render action: :edit end end - # DELETE /page_elements/1 - # DELETE /page_elements/1.json def destroy @page_element.destroy - respond_to do |format| - format.html { redirect_to council_page_page_elements_path(@council) } - format.json { head :no_content } - end + redirect_to @page end private - # Use callbacks to share common setup or constraints between actions. - def set_page_element - @page_element = PageElement.find(params[:id]) - end - def set_council - @council = Council.find_by_url(params[:council_id]) - @page = @council.page - end - # Never trust parameters from the scary internet, only allow the white list through. - def page_element_params - params.fetch(:page_element).permit(:page_id,:displayIndex, :sidebar, :visible,:text, :headline, :border, :name, :pictureR,:picture) - end + def page_element_params + params.fetch(:page_element).permit(:page_id, :displayIndex, :sidebar, + :visible, :text, :headline, :border, + :name, :pictureR, :picture) + end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c9f727db1..8475c802c 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,84 +1,40 @@ # encoding:UTF-8 class PagesController < ApplicationController - before_action :set_page, only: [:show, :edit, :update, :destroy] + load_permissions_and_authorize_resource find_by: :url - # GET /pages - # GET /pages.json def index - @pages = @page.page_elements end - # GET /pages/1 - # GET /pages/1.json def show - if (@page) - @mainelements = @page.page_elements.where(visible: true,sidebar: false) - @sidebarelements = @page.page_elements.where(visible:true,sidebar: true) - end - if(@mainelemnents) && (@mainelements.count > 1) - @mainelements = @mainelements.sort_by{ |x| x[:displayIndex]} - end - @poster = @council.posts end - # GET /pages/new def new - @page = Page.new end - # GET /pages/1/edit def edit end - # POST /pages - # POST /pages.json def create - @page = Page.new(page_params) - - respond_to do |format| - if @page.save - format.html { redirect_to @page, notice: 'Sidan skapades, success!.' } - format.json { render action: 'show', status: :created, location: @page } - else - format.html { render action: 'new' } - format.json { render json: @page.errors, status: :unprocessable_entity } - end - end + flash[:notice] = 'Sidan skapades, success!.' if @page.save + redirect_to @page end - # PATCH/PUT /pages/1 - # PATCH/PUT /pages/1.json def update - respond_to do |format| - if @page.update(page_params) - format.html { redirect_to @page, notice: 'Sidan uppdaterades, great!' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @page.errors, status: :unprocessable_entity } - end + if @page.update(page_params) + redirect_to @page, notice: 'Sidan uppdaterades, great!' + else + render action: :edit end end - # DELETE /pages/1 - # DELETE /pages/1.json def destroy @page.destroy - respond_to do |format| - format.html { redirect_to pages_url } - format.json { head :no_content } - end + redirect_to pages_url end private - # Use callbacks to share common setup or constraints between actions. - def set_page - @council = Council.find_by_url(params[:council_id]) - @page = @council.page - end - # Never trust parameters from the scary internet, only allow the white list through. - def page_params - params.fetch(:page).permit(:council_id) - end + def page_params + params.fetch(:page).permit(:council_id, :url, :visible, :title) + end end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 988c4acb2..b854eb99e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,102 +1,63 @@ # encoding:UTF-8 class PostsController < ApplicationController load_permissions_and_authorize_resource - before_action :set_council + load_and_authorize_resource :council, parent: true, find_by: :url + before_action :set_permissions + before_action :set_councils, only: [:new, :edit, :update, :create] + before_action :set_profile, only: [:remove_profile, :add_profile] def remove_profile - @profile = Profile.find_by_id(params[:profile_id]) - @post.profiles.delete(@profile) - respond_to do |format| - format.html { redirect_to council_posts_path(@council), notice: @profile.name.to_s + ' har inte längre posten ' + @post.title.to_s + '.' } - end + @post.remove_profile(@profile) + redirect_to back, + notice: %(#{@profile.full_name} har inte längre posten #{@post.title}.) end - def add_profile_username - @user = User.find_by(username: params[:username]) - if @user != nil - @profile = @user.profile - end - if @profile == nil - respond_to do |format| - format.html { redirect_to council_posts_path(@council), flash: {alert: 'Hittade ingen användare med det användarnamnet.'} } - end - elsif @profile.name.blank? - redirect_to council_posts_path(@council), flash: {alert: 'Användaren :"' + @user.username.to_s + '" måste fylla i fler uppgifter i sin profil.'} - elsif @profile.posts.include?(@post) - redirect_to council_posts_path(@council), flash: {alert: @profile.name.to_s + '(' + @user.username.to_s + ') har redan posten '+@post.title.to_s + '.'} - elsif (@post.limit != nil) && (@post.profiles.size >= @post.limit) - redirect_to council_posts_path(@council), flash: {alert: @post.title.to_s + ' har sitt maxantal.'} + def add_profile + if @post.add_profile(@profile) + flash[:notice] = %(#{@profile.full_print} tilldelades #{@post}) else - @post.profiles << @profile - redirect_to council_posts_path(@council), notice: @profile.name.to_s + ' (' + @profile.user.username.to_s + ') tilldelades posten '+@post.title.to_s + '.' - if (@profile.first_post == nil) - @profile.update(first_post: @post.id) - end + flash[:alert] = %(Tilldelningen gick inte: #{@post.errors.full_messages}) end + redirect_to back end def index - if (@council) - @posts = @council.posts - else - @posts = Post.all - end + @posts = (@council.present?) ? @council.posts : Post.all @post_grid = initialize_grid(@posts) end def new @post = @council.posts.build - @councils = Council.order(title: :asc) + @post_permissions = @post.permissions.collect! { |p| p.id } end def edit @post_permissions = @post.permissions.collect! { |p| p.id } - @councils = Council.order(title: :asc) - @permissions = Permission.all end def create - @councils = Council.order(title: :asc) @post = @council.posts.build(post_params) - respond_to do |format| - if @post.save - format.html { redirect_to council_posts_path(@council), notice: 'Posten skapades!' } - format.json { render action: 'show', status: :created, location: @post } - else - format.html { render action: 'new' } - format.json { render json: @posts.errors, status: :unprocessable_entity } - end + if @post.save + redirect_to council_posts_path(@council), notice: 'Posten skapades!' + else + render action: 'new' end end def update - respond_to do |format| - @post.attributes = post_params - @post.permissions = [] - @post.set_permissions(params[:permissions]) if params[:permissions] - if @post.save - @council2 = Council.find_by_id(params[:post][:council]) - if (@council2) && (@council2.equal?(@council) == false) - @council2.posts << @post - @council = @council2 - end - format.html { redirect_to edit_council_post_path(@council, @post), notice: 'Posten uppdaterades!' } - format.json { head :no_content } - else - @councils = Council.order(title: :asc) - format.html { render action: 'edit' } - format.json { render json: @post.errors, status: :unprocessable_entity } - end + @post.attributes = post_params + @post.permissions = [] + @post.set_permissions(params[:permissions]) if params[:permissions] + if @post.save + redirect_to edit_council_post_path(@post.council, @post), notice: 'Posten uppdaterades!' + else + render action: 'edit' end end def destroy - @post.profiles.clear @post.destroy - respond_to do |format| - format.html { redirect_to council_posts_path(@council) } - format.json { head :no_content } - end + redirect_to council_posts_path(@council) end def display @@ -113,8 +74,22 @@ def post_params :styrelse, :car_rent, :council_id, :permissions) end - def set_council - @council = Council.find_by_url(params[:council_id]) + def set_councils + @councils = Council.order(title: :asc) + end + + def set_permissions + @permissions = Permission.all end -end + def set_profile + if @post.nil? + @post = Post.find_by_id(params[:post_id]) + end + @profile = Profile.find_by_id(params[:profile_id]) + end + + def back + @council.present? ? council_posts_path(@council) : posts_path + end +end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 5d9a32013..98ff8b7a3 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -10,61 +10,50 @@ def show def edit - redirect_to(:back) unless current_user.profile == @profile # Calls method to set the first_post attribute if not set # /d.wessman @profile.check_posts - rescue ActionController::RedirectBackError - redirect_to root_path + rescue ActionController::RedirectBackError + redirect_to root_path end def update - respond_to do |format| - if @profile.update(profile_params) - format.html { redirect_to @profile, notice: %(#{t(:your_profile)} #{t(:success_update)}) } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @profile.errors, status: :unprocessable_entity } - end + if @profile.update(profile_params) + redirect_to @profile, notice: %(#{t(:your_profile)} #{t(:success_update)}) + else + render action: 'edit' end end def remove_post @post = Post.find(params[:post_id]) @profile.posts.delete(@post) - respond_to do |format| - format.html { redirect_to edit_profile_path(@profile), notice: 'Du har inte längre posten '+@post.title + '.'} - if @profile.posts.count == 0 - @profile.update(first_post: nil) - end - end + redirect_to edit_profile_path(@profile), notice: %(Du har inte längre posten #{@post}.) + @profile.check_posts end # Action to show profile picture only already authenticated def avatar if @profile.avatar? - if(params[:style] == "original" || params[:style] == "medium" || params[:style] == "thumb") - send_file(@profile.avatar.path(params[:style]), filename:@profile.avatar_file_name, type: "image/jpg",disposition: 'inline',x_sendfile: true) + if params[:style] == 'original' || params[:style] == 'medium' || params[:style] == 'thumb' + send_file(@profile.avatar.path(params[:style]), filename: @profile.avatar_file_name, + type: 'image/jpg', disposition: 'inline', x_sendfile: true) else - send_file(@profile.avatar.path(:medium), filename:@profile.avatar_file_name, type: "image/jpg",disposition: 'inline',x_sendfile: true) + send_file(@profile.avatar.path(:medium), filename: @profile.avatar_file_name, + type: 'image/jpg', disposition: 'inline', x_sendfile: true) end end end - private - def authenticate - redirect_to root_path unless current_user && (current_user == @profile.user) - end - # Use callbacks to share common setup or constraints between actions. - def set_profile - @profile = Profile.find_by_id(params[:id]) - end + def search + @search_profiles = Profile.search_names(params[:firstname], params[:lastname]) + end - # Never trust parameters from the scary internet, only allow the white list through. - def profile_params - params.require(:profile).permit(:name,:lastname, :program, :start_year,:avatar,:first_post,:stil_id,:email,:phone) - end + private + def profile_params + params.require(:profile).permit(:name, :lastname, :program, :start_year, + :avatar, :first_post, :stil_id, :email, :phone) + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b6ef1164d..cf051f264 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,70 +1,44 @@ # encoding:UTF-8 -class UsersController < ApplicationController +class UsersController < ApplicationController load_permissions_and_authorize_resource - before_filter :find_user, :only => [:edit, :update,:destroy,:update_password] - before_filter :owner_required, :only => [:edit, :update] - - def change_role - @user = User.find params[:user_id] - @role = Role.find params[:role_id] - @user.update_attribute(:role, @role) - redirect_to users_path - end - - def index - @users = User.all + + def index end - def update_password - respond_to do |format| - if @user.update_with_password(user_params) - format.html { redirect_to :edit_user_registration, notice: 'Användaruppgifter uppdaterades.' } - format.json { head :no_content } - else - format.html{ redirect_to :edit_user_registration , notice: 'Lösenord måste fyllas i för att ändra uppgifter.' } - format.json { head :no_content } - end - end - end + def update_password + if @user.update_with_password(user_params) + redirect_to :edit_user_registration, notice: 'Användaruppgifter uppdaterades.' + else + redirect_to :edit_user_registration, notice: 'Lösenord måste fyllas i för att ändra uppgifter.' + end + end - def update - @user.update(user_params) - flash[:notice] = 'Användare uppdaterades.' - redirect_to edit_user_path @users + def update + if @user.update(user_params) + flash[:notice] = 'Användare uppdaterades.' + redirect_to edit_user_path @user + else + redirect_to :edit_user_registration + end end def destroy - respond_to do |format| - if @user.update_with_password(user_params) - @user.profile.posts.clear - if @user.destroy - - format.html { redirect_to root_url, notice: 'Användare togs bort..' } - format.json { head :no_content } - end - else - format.html{ redirect_to :edit_user_registration , notice: 'Lösenord måste fyllas i för att radera användare.' } - format.json { head :no_content } + if @user.update_with_password(user_params) + @user.profile.posts.clear + if @user.destroy + redirect_to root_url, notice: 'Användare togs bort.' end + else + redirect_to :edit_user_registration, + notice: 'Lösenord måste fyllas i för att radera användare.' end end - private - def user_params - params.require(:user).permit(:username, :email, :password, :password_confirmation, :current_password) - end - def authenticate_admin! - flash[:error] = t('the_role.access_denied') - redirect_to(:back) unless current_user && current_user.moderator?(:users) - rescue ActionController::RedirectBackError - redirect_to root_path - end - def find_user - @user = User.find(params[:id]) + private - # TheRole: You should define OWNER CHECK OBJECT - # When editable object was found - - @owner_check_object = @user + def user_params + params.require(:user).permit(:username, :email, + :password, :password_confirmation, + :current_password) end end diff --git a/app/controllers/work_posts_controller.rb b/app/controllers/work_posts_controller.rb index f50c9ae6e..6741504d5 100644 --- a/app/controllers/work_posts_controller.rb +++ b/app/controllers/work_posts_controller.rb @@ -1,92 +1,56 @@ # encoding:UTF-8 -class WorkPostsController < ApplicationController - - before_filter :authenticate_user! - before_filter :authenticate, only: [:new, :create,:edit,:destroy,:update] +class WorkPostsController < ApplicationController + load_permissions_and_authorize_resource before_action :set_edit - before_action :set_work_post, except: [:index,:new,:create] - - def index @work_posts = WorkPost.publish @work_post_grid = initialize_grid(WorkPost.publish) @not_published_grid = initialize_grid(WorkPost.unpublish) - if(WorkPost.unpublish.count > 0) + if WorkPost.unpublish.count > 0 @edit_grid = true end end - - def show + def show end - + def new - @work_post = WorkPost.new end - + def edit end - + def create - @work_post = WorkPost.new(work_post_params) @work_post.responsible = current_user.profile.id - respond_to do |format| - if @work_post.save - format.html { redirect_to work_posts_path, notice: 'Jobbposten skapades, success!.' } - format.json { render action: 'show', status: :created, location: @work_post } - else - format.html { render action: 'new' } - format.json { render json: @work_post.errors, status: :unprocessable_entity } - end + if @work_post.save + redirect_to work_posts_path, notice: 'Jobbposten skapades, success!.' + else + render action: 'new' end end def update - respond_to do |format| - if @work_post.update(work_post_params) - format.html { redirect_to work_posts_path, notice: 'Jobbposten uppdaterades, gött' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @work_post.errors, status: :unprocessable_entity } - end + if @work_post.update(work_post_params) + redirect_to work_posts_path, notice: 'Jobbposten uppdaterades, gött' + else + render action: 'edit' end end def destroy @work_post.destroy - respond_to do |format| - format.html { redirect_to work_posts_path,notice: 'Jobbposten raderades.' } - format.json { head :no_content } - end + redirect_to work_posts_path, notice: 'Jobbposten raderades.' end private - def authenticate - flash[:error] = t('the_role.access_denied') - redirect_to(:back) unless current_user.moderator?(:jobbportal) - - rescue ActionController::RedirectBackError - redirect_to root_path - end - def set_edit - if(current_user) && (current_user.moderator?(:jobbportal)) - @edit = true - else - @edit = false - end - end - # Use callbacks to share common setup or constraints between actions. - def set_work_post - @work_post = WorkPost.find_by_id(params[:id]) - if(@work_post == nil) - @work_post = WorkPost.new() - end - end - # Never trust parameters from the scary internet, only allow the white list through. - def work_post_params - params.fetch(:work_post).permit(:title,:description,:company,:deadline,:kind,:for,:visible,:publish,:picture,:category,:link) - end + def set_edit + @edit = can?(:manage, WorkPost) + end + + def work_post_params + params.fetch(:work_post).permit(:title, :description, :company, :deadline, + :kind, :for, :visible, :publish, :picture, :category, :link) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d43c0a2a..1efe7c296 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,15 +3,28 @@ def fa_icon(icon_name) content_tag :i, nil, class: ("fa fa-" + icon_name) end + def model_name(model) + if model.instance_of?(Class) + model.model_name.human + end + end + + def models_name(model) + if model.instance_of?(Class) + return model.model_name.human(count: 2) + end + end + def title(page_title) content_for(:title) { page_title } end + def full_title(page_title) - base_title = "F-sektionen" + base_title = 'F-sektionen' if page_title.empty? base_title else - "#{base_title} | #{page_title}" + %(#{base_title} | #{page_title}) end end @@ -24,6 +37,6 @@ def form_group &block e['class'] = 'form-control ' end end - content_tag :div, raw(html.to_html), :class => 'form-group' + content_tag :div, raw(html.to_html), class: 'form-group' end end diff --git a/app/helpers/constants_helper.rb b/app/helpers/constants_helper.rb deleted file mode 100644 index 1fb532fb0..000000000 --- a/app/helpers/constants_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ConstantsHelper -end diff --git a/app/models/ability.rb b/app/models/ability.rb index ce5a8cfb1..288fefc3a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -7,29 +7,32 @@ def initialize(user) user.profile ||= Profile.new # Abilities that everyone get. - can :read, News - can :read, Council - can :read, Election + can :read, [News, Council, Page, Election] can :read, Document, public: true + can [:display, :image], Notice + can [:collapse, :display], Post + + # For calendar-subscription + can :export, Event # TODO Should be removed when everyone is required to log in. # /d.wessman 2015-03-28 can [:read, :update_worker, :remove_worker, :authorize], CafeWork - can [:read, :main], Rent + can [:read, :main, :new, :edit, :create, :update, :destroy, :authorize], Rent # Abilities all signed in users get if user.id - can :nominate, Election - can :candidate, Election + can :manage, User, id: user.id + can [:nominate, :candidate], Election can :manage, Candidate, profile_id: user.profile.id + can :manage, Nomination + can [:show, :avatar], Profile can :manage, Profile, user_id: user.id - can :read, Post + can [:read, :display, :hide], Post can :read, Document can :read, :old_gallery - can :read, Event - # TODO We really need to move calendar to its own controller - can :calendar, Event + can [:read, :calendar], Event end # Note: Root access is given dynamically by having a post with permissions :manage, :all diff --git a/app/models/cafe_work.rb b/app/models/cafe_work.rb index a4a631e56..b2ebe4a23 100644 --- a/app/models/cafe_work.rb +++ b/app/models/cafe_work.rb @@ -8,7 +8,7 @@ class CafeWork < ActiveRecord::Base # Validations validates :work_day, :pass, :lp, :lv, presence: true validates :pass, :lp, inclusion: { in: 1..4 } - validates :lv, inclusion: { in: 1..7 } + validates :lv, inclusion: { in: 1..20 } validates :name, :lastname, :phone, :email, presence: true, if: :has_worker? validates :pass, uniqueness: { scope: [:work_day, :lv, :lp, :d_year] } diff --git a/app/models/candidate.rb b/app/models/candidate.rb index 1e2e9d516..847445140 100644 --- a/app/models/candidate.rb +++ b/app/models/candidate.rb @@ -7,7 +7,7 @@ class Candidate < ActiveRecord::Base # Validations validates :profile_id, uniqueness: { - scope: [:post_id, :election_id], message: 'har redan en likadan kandidatur' + scope: [:post_id, :election_id], message: I18n.t('candidates.similar_candidate') }, on: :create validates :name, :lastname, :stil_id, :email, :phone, :post, :profile, :election, presence: true @@ -31,26 +31,18 @@ def prepare(user) end def editable? - election.view_status == 2 || post.elected_by == 'Studierådet' + election.view_status == :during || post.elected_by == 'Studierådet' end def p_url - Rails.application.routes.url_helpers.election_candidate_url(id, host: PUBLIC_URL) + Rails.application.routes.url_helpers.candidate_url(id, host: PUBLIC_URL) end def p_path - Rails.application.routes.url_helpers.election_candidate_path(id) + Rails.application.routes.url_helpers.candidate_path(id) end def owner?(user) user.present? && user.profile == profile end - - def editable? - election.view_status == 2 || post.elected_by == 'Studierådet' - end - - def p_url - Rails.application.routes.url_helpers.election_candidate_url(id, host: PUBLIC_URL) - end end diff --git a/app/models/council.rb b/app/models/council.rb index bb9777431..b98d9316e 100644 --- a/app/models/council.rb +++ b/app/models/council.rb @@ -3,8 +3,8 @@ class Council < ActiveRecord::Base # Associations has_one :page, dependent: :destroy - belongs_to :president, foreign_key: :president, class_name: :Post - belongs_to :vice_president, foreign_key: :vice_president, class_name: :Post + belongs_to :president, foreign_key: :president_id, class_name: :Post + belongs_to :vice_president, foreign_key: :vicepresident_id, class_name: :Post has_many :posts has_many :profiles, through: :posts @@ -15,6 +15,16 @@ class Council < ActiveRecord::Base validates :title, :url, presence: true validates :url, uniqueness: true + after_update :check_page + + def check_page + if page.nil? + build_page(url: url, visible: true, title: title).save! + elsif page.url.nil? + page.update!(url: url, visible: true, title: title) + end + end + def to_s title end diff --git a/app/models/election.rb b/app/models/election.rb index 0fa742c7c..92e70178c 100644 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -3,93 +3,97 @@ class Election < ActiveRecord::Base has_many :nominations, dependent: :destroy has_many :candidates, dependent: :destroy has_and_belongs_to_many :posts - + validates :url, presence: true, uniqueness: true def self.current self.order(start: :asc).where(visible: true).first || nil end - # Returns a number to load different views - # 1: before the election opens - # 2: during the election - # 3: after the election + def termin_grid + if (p = posts.termins).count > 0 + initialize_grid(p, name: 'election') + end + end + + def rest_grid + if (p = posts.not_termins).count > 0 + initialize_grid(p, name: 'election') + end + end + # Returns current status # /d.wessman def view_status - if self.start > Time.zone.now - return 1 - elsif (self.start <= Time.zone.now) && (self.end > Time.zone.now) - return 2 + if start > Time.zone.now + return :before + elsif start <= Time.zone.now && self.end > Time.zone.now + return :during else - return 3 + return :after end end # Returns a status text depending on the view_status # /d.wessman def status_text - i = view_status - if i == 1 - return self.text_before - elsif i == 2 - return self.text_during - else - return self.text_after + case view_status + when :before + text_before + when :during + text_during + when :after + text_after end end # Returns a status text for the nominations page # /d.wessman def nomination_status - if view_status != 3 - return "" + if view_status == :after + I18n.t('nominations.status_after') end - return "Det går endast att nominera till poster som inte väljs på Terminsmötet" end + # Returns the current posts # /d.wessman def current_posts - if view_status != 3 - posts - else + if view_status == :after posts.not_termins + else + posts end end # Returns the start_date if before, the end_date if during and none if after. # /d.wessman def countdown - i = view_status - if i == 1 - return self.start - elsif i == 2 - return self.end + case view_status + when :before + start + when :during + self.end end - nil end def candidate_count(post) if post.present? - self.candidates.where(post_id: post.id).count + candidates.where(post_id: post.id).count else 0 end end def can_candidate?(post) - if post.elected_by == "Terminsmötet" && view_status == 2 + if post.elected_by == 'Terminsmötet' && view_status == :during return true - elsif post.elected_by != "Terminsmötet" && view_status != 1 + elsif post.elected_by != 'Terminsmötet' && view_status != :before return true end - return false + + false end def to_param - if (self.url) - self.url - else - self.id - end + (url.present?) ? url : id end end diff --git a/app/models/list.rb b/app/models/list.rb deleted file mode 100644 index b12f786a6..000000000 --- a/app/models/list.rb +++ /dev/null @@ -1,3 +0,0 @@ -# encoding: UTF-8 -class List < ActiveRecord::Base -end diff --git a/app/models/page.rb b/app/models/page.rb index dd736bc20..306f14a82 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,5 +1,23 @@ # encoding: UTF-8 class Page < ActiveRecord::Base -belongs_to :council -has_many :page_elements + # Associations + belongs_to :council + has_many :page_elements + + # Validations + validates :url, uniqueness: true, if: 'url.present?' + + # Scopes + + def main + page_elements.main + end + + def side + page_elements.side + end + + def to_param + url.present? ? url : id + end end diff --git a/app/models/page_element.rb b/app/models/page_element.rb index fa1042717..faeb57982 100644 --- a/app/models/page_element.rb +++ b/app/models/page_element.rb @@ -1,9 +1,16 @@ # encoding: UTF-8 class PageElement < ActiveRecord::Base - belongs_to :page - has_attached_file :picture, - :styles => { original: "4000x4000>", large: "1500x1500>", small: "250x250>",thumb: "100x100>" }, - :path => ":rails_root/public/system/images/sidor/element/:id/:style/:filename", - :url => "/system/images/sidor/element/:id/:style/:filename" - validates_attachment_content_type :picture, :content_type => /\Aimage\/.*\Z/ + belongs_to :page + has_attached_file :picture, + styles: { original: '4000x4000>', large: '1500x1500>', + small: '250x250>', thumb: '100x100>' }, + path: ':rails_root/public/system/images/sidor/element/:id/:style/:filename', + url: '/system/images/sidor/element/:id/:style/:filename' + validates_attachment_content_type :picture, content_type: /\Aimage\/.*\Z/ + + scope :visible, -> { where(visible: true) } + scope :main, -> { visible.where(sidebar: false).index } + scope :side, -> { visible.where(sidebar: true).index } + scope :index, -> { order(:displayIndex) } + scope :rest, -> { where(visible: false) } end diff --git a/app/models/permission.rb b/app/models/permission.rb index bb7c7236b..5952c7069 100644 --- a/app/models/permission.rb +++ b/app/models/permission.rb @@ -1,5 +1,5 @@ class Permission < ActiveRecord::Base - has_many :posts, through: 'permission_post' + has_many :posts, through: :permission_posts has_many :permission_posts validates :subject_class, :action, presence: true end diff --git a/app/models/post.rb b/app/models/post.rb index c38e69a66..77225639b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -4,33 +4,66 @@ class Post < ActiveRecord::Base belongs_to :council has_and_belongs_to_many :profiles has_many :nominations - has_many :candidates + has_many :candidates has_many :permission_posts - has_many :permissions, through: 'permission_posts' + has_many :permissions, through: :permission_posts # Scopes - scope :studierad, -> {where(elected_by: "Studierådet").order(council_id: :asc)} - scope :termins, -> {where(elected_by: "Terminsmötet").order(council_id: :asc)} + scope :studierad, -> { where(elected_by: 'Studierådet').order(council_id: :asc) } + scope :termins, -> { where(elected_by: 'Terminsmötet').order(council_id: :asc) } - scope :not_termins, -> {where.not(elected_by: "Terminsmötet").order(council_id: :asc)} + scope :not_termins, -> { where.not(elected_by: 'Terminsmötet').order(council_id: :asc) } # Validations - validates_presence_of :limit,:recLimit, :description + validates :limit, :recLimit, :description, presence: true # Scopes - scope :renters, -> {where(car_rent:true)} - + scope :renters, -> { where(car_rent: true) } + + def to_s + title + end + def printLimit - if((recLimit == 0) && (limit == 0)) || (recLimit > limit ) + if recLimit == 0 && limit == 0 || recLimit > limit "*" - elsif(recLimit == limit) && (recLimit > 0) - limit.to_s + " (x)" - elsif(limit > 0) && (recLimit == 0) - limit.to_s - elsif(limit > recLimit) - recLimit.to_s + "-" + limit.to_s + elsif recLimit == limit && recLimit > 0 + %(#{limit} (x)) + elsif limit > 0 && recLimit == 0 + limit + elsif limit > recLimit + %(#{recLimit}- #{limit}) end - end + end + + def limited? + limit > 0 && profiles.count >= limit + end + + def add_profile(profile) + if profile.nil? + errors.add(:profile, I18n.t('errors.messages.not_found')) + return false + end + + if profiles.include?(profile) + errors.add(:profile, I18n.t('posts.already_have_post')) + return false + end + + if limited? + errors.add(:limit, I18n.t('posts.limited')) + return false + end + + profiles << profile + true + end + + def remove_profile(profile) + profiles.delete(profile) + end + def set_permissions(permissions) permissions.each do |id| #find the main permission assigned from the UI diff --git a/app/models/profile.rb b/app/models/profile.rb index b21016f9e..4217892ed 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -6,6 +6,8 @@ class Profile < ActiveRecord::Base has_many :candidates has_many :rents has_many :councils, through: :posts + # TODO Change the first_post field to first_post_id + # belongs_to :first_post, foreign_key: first_post_id, class: Post # Attachment has_attached_file :avatar, @@ -16,17 +18,25 @@ class Profile < ActiveRecord::Base validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/ # Only on update! validates :name, :lastname, presence: true, on: :update - validates :start_year, inclusion: { in: 1954..(Time.zone.today.year + 1) }, on: :update + validates :start_year, inclusion: {in: 1954..(Time.zone.today.year + 1)}, on: :update + + scope :search_names, ->(name, lastname) { + where('name LIKE ? AND lastname LIKE ?', "%#{name}%", "%#{lastname}%") + } def full_name "#{name} #{lastname}".strip end + def full_print + "#{full_name} ( User: #{user_id})".strip + end + # Returns all councils the profile belongs to with a Post who is # allowed to rent the car # /d.wessman def car_councils - self.councils.merge(Post.renters) + councils.merge(Post.renters) end # Check if profile has user data (name and lastname) diff --git a/app/views/admin/cafe_works/new.html.erb b/app/views/admin/cafe_works/new.html.erb index 2d2ffb2a4..70452c60c 100644 --- a/app/views/admin/cafe_works/new.html.erb +++ b/app/views/admin/cafe_works/new.html.erb @@ -1,9 +1,9 @@
- <%= label_tag 'Cafejobb',nil, :class => 'reg-header'%> + <%= label_tag 'Cafejobb',nil, class: 'reg-header'%> <%= render 'form'%> - <%= link_to 'Tillbaka till cafebokning', :admin_cafe_works %> + <%= link_to 'Tillbaka till cafebokning', :admin_hilbert %>
-
\ No newline at end of file + diff --git a/app/views/admin/elections/edit.html.erb b/app/views/admin/elections/edit.html.erb index 21159312f..18288535f 100644 --- a/app/views/admin/elections/edit.html.erb +++ b/app/views/admin/elections/edit.html.erb @@ -3,37 +3,37 @@
<%= form_for([:admin,@election]) do |f| %> - <%= label_tag 'Redigera val',nil, :class => 'reg-header'%>
- <%= f.label 'Huvudtext i nomineringsmejl', :class => 'reg-label'%> + <%= label_tag 'Redigera val',nil, class: 'reg-header'%>
+ <%= f.label 'Huvudtext i nomineringsmejl', class: 'reg-label'%>
- <%= f.text_area :nominate_mail,:class => 'form-control', size: "180x4" %> + <%= f.text_area :nominate_mail,class: 'form-control', size: "180x4" %>
- <%= f.label 'Huvudtext i valberedningens kandidaturmejl', :class => 'reg-label'%> + <%= f.label 'Huvudtext i valberedningens kandidaturmejl', class: 'reg-label'%>
- <%= f.text_area :candidate_mail,:class => 'form-control', size: "180x4" %> + <%= f.text_area :candidate_mail,class: 'form-control', size: "180x4" %>
- <%= f.label 'Huvudtext i kandidaturmejl för stjärnposter', :class => 'reg-label'%> + <%= f.label 'Huvudtext i kandidaturmejl för stjärnposter', class: 'reg-label'%>
- <%= f.text_area :candidate_mail_star,:class => 'form-control', size: "180x4" %> + <%= f.text_area :candidate_mail_star,class: 'form-control', size: "180x4" %>
- <%= f.label 'Extratext i styrelsemejl', :class => 'reg-label'%> + <%= f.label 'Extratext i styrelsemejl', class: 'reg-label'%>
- <%= f.text_area :extra_text,:class => 'form-control', size: "180x4" %> + <%= f.text_area :extra_text,class: 'form-control', size: "180x4" %>
- <%= f.label 'Text innan valet är öppet', :class => 'reg-label'%> + <%= f.label 'Text innan valet är öppet', class: 'reg-label'%>
- <%= f.text_area :text_before,:class => 'form-control', size: "180x4" %> + <%= f.text_area :text_before,class: 'form-control', size: "180x4" %>
- <%= f.label 'Text under valet', :class => 'reg-label'%> + <%= f.label 'Text under valet', class: 'reg-label'%>
- <%= f.text_area :text_during,:class => 'form-control', size: "180x4" %> + <%= f.text_area :text_during,class: 'form-control', size: "180x4" %>
- <%= f.label 'Text efter valet', :class => 'reg-label'%> + <%= f.label 'Text efter valet', class: 'reg-label'%>
- <%= f.text_area :text_after,:class => 'form-control', size: "180x4" %> + <%= f.text_area :text_after,class: 'form-control', size: "180x4" %>
- <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
<%end%> <%= link_to 'Redigera inställningar', admin_election_path(@election) %>
@@ -94,4 +94,4 @@ Valberedningen

- \ No newline at end of file + diff --git a/app/views/admin/elections/index.html.erb b/app/views/admin/elections/index.html.erb index 5db33e79d..a7f8662f3 100644 --- a/app/views/admin/elections/index.html.erb +++ b/app/views/admin/elections/index.html.erb @@ -1,8 +1,39 @@ -
- - <% @elections.each do |elec|%> -
  • <%=link_to(elec.title,admin_election_path(elec))%>
  • - <%end%> - - <%=link_to('Nytt val',new_admin_election_path)%> +
    +
    +
    +
    +

    + Sektionsval

    + <%=link_to('Nytt val',new_admin_election_path, class: 'btn btn-u')%> +
    + + + + + + + + + + + + + + + <% @elections.each do |election| %> + + + + + + + + + + + <% end %> + +
    TitelUrlSynligÖppnarStängerAktuellt val?UppdateradRedigera
    <%= election.title %><%= election.url %><%= election.visible %><%= election.start%><%= election.end%><%= (election == Election.current) ? 'Sant': 'Falskt'%><%= election.updated_at %><%= link_to('Redigera', admin_election_path(election), class: "btn btn-u") %>
    +
    +
    diff --git a/app/views/admin/rents/_form.html.erb b/app/views/admin/rents/_form.html.erb index 5cb4e4f26..e009b3447 100644 --- a/app/views/admin/rents/_form.html.erb +++ b/app/views/admin/rents/_form.html.erb @@ -7,9 +7,9 @@
    <%= f.label 'Disclaimer', class: 'reg-label' %> - <%= f.check_box :disclaimer, id: "accepted_disclaimer" %> + <%= f.check_box :disclaimer, id: "accepted_disclaimer", checked: true %> <%= f.label 'Service', class: 'reg-label' %> - <%= f.check_box :services %> + <%= f.check_box :service %>
    <%= f.label 'Namn & Efternamn', class: 'reg-label' %> @@ -21,8 +21,8 @@ <%= f.label 'E-post & telefon', class: 'reg-label' %>
    -
    <%= f.text_field :email, class: 'form-control', placeholder: "Epost" %>
    -
    <%= f.text_field :phone, class: 'form-control', placeholder: "Telefon" %>
    +
    <%= f.email_field :email, class: 'form-control', placeholder: "Epost" %>
    +
    <%= f.phone_field :phone, class: 'form-control', placeholder: "Telefon" %>
    <%= f.label 'Syfte', class: 'reg-label' %> @@ -31,18 +31,17 @@
    <%= f.label 'Från', class: 'reg-label' %>
    - <%= f.datetime_select :d_from, minute_step: 10, class: 'form-control' %> + <%= f.text_field :d_from, class: 'form-control datetimepicker1' %>
    <%= f.label 'Till', class: 'reg-label' %>
    - <%= f.datetime_select :d_til, minute_step: 10, class: 'form-control' %> + <%= f.text_field :d_til, class: 'datetimepicker2'%>
    <%= f.label 'Utskott', class: 'reg-label' %>
    - <%= f.select :council_id, - options_from_collection_for_select(@councils, :id, :title, @rent.council_id), - include_blank: true, - class: "form-control listBox" %> + <%= f.collection_select(:council, Council.all, :id,:title, + include_blank: true, class: 'form-control listBox')%> +
    <%= f.label :status, class: 'reg-label' %> @@ -62,8 +61,9 @@ <%= f.text_area :comment, class: 'form-control' %>
    - <%= f.submit "Spara", class: "btn btn-u", data: {confirm: 'Som administratör bokar man över vad som helst (utan att påverka bokningen), ingenting valideras.'} %> + <%= f.submit "Spara", id: 'rent-submit', class: "btn btn-u", + data: {confirm: 'Som administratör bokar man över vad som helst (utan att påverka bokningen), ingenting valideras.'} %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb index d3fca1ccd..b496f27fd 100644 --- a/app/views/albums/_form.html.erb +++ b/app/views/albums/_form.html.erb @@ -11,35 +11,35 @@ <% end %>
    - <%= f.label 'Titel', :class => 'reg-label'%> + <%= f.label 'Titel', class: 'reg-label'%>
    - <%= f.text_field :title, :class => 'form-control',:placeholder => 'Titel'%> + <%= f.text_field :title, class: 'form-control',:placeholder => 'Titel'%>
    - <%= f.label 'Beskrivning', :class => 'reg-label'%> + <%= f.label 'Beskrivning', class: 'reg-label'%>
    - <%= f.text_area :description, :class => 'form-control',:placeholder => 'Beskrivning',size: "40x5" %> + <%= f.text_area :description, class: 'form-control',:placeholder => 'Beskrivning',size: "40x5" %>
    - <%= f.label 'Plats', :class => 'reg-label'%> + <%= f.label 'Plats', class: 'reg-label'%>
    - <%= f.text_field :location, :class => 'form-control',:placeholder => 'Plats',:autocomplete => 'off' %> + <%= f.text_field :location, class: 'form-control',:placeholder => 'Plats',:autocomplete => 'off' %>
    - <%= f.label 'Start', :class => 'reg-label'%> + <%= f.label 'Start', class: 'reg-label'%>
    - <%= f.date_field :start_date, :class => 'form-control' %> + <%= f.date_field :start_date, class: 'form-control' %>
    - <%= f.label 'Slut', :class => 'reg-label'%> + <%= f.label 'Slut', class: 'reg-label'%>
    - <%= f.date_field :end_date, :class => 'form-control' %> + <%= f.date_field :end_date, class: 'form-control' %>
    - <%= f.label 'Kategori', :class => 'reg-label'%> + <%= f.label 'Kategori', class: 'reg-label'%> <%if @kategorier%>
    <%for @cat in @kategorier%>
    - <%= f.check_box(:album_category_ids,{multiple: true},@cat.id,nil)%><%= f.label :album_category_id, @cat.name, :value => false,:class => 'reg-label' %> + <%= f.check_box(:album_category_ids,{multiple: true},@cat.id,nil)%><%= f.label :album_category_id, @cat.name, :value => false,class: 'reg-label' %>
    <%end%> Just nu kan man välja flera, men bara för att man kan, så behöver man inte göra det! :)
    @@ -47,18 +47,18 @@
    <%end%> <%if @subcategories%> - <%= f.label 'Underkategorier', :class => 'reg-label'%> + <%= f.label 'Underkategorier', class: 'reg-label'%> <%for @subcat in @subcategories%>
    - <%= f.check_box(:subcategory_ids,{multiple: true},@subcat.id,nil)%><%= f.label :subcategory_id, @subcat.text, :value => false,:class => 'reg-label' %> + <%= f.check_box(:subcategory_ids,{multiple: true},@subcat.id,nil)%><%= f.label :subcategory_id, @subcat.text, :value => false,class: 'reg-label' %>
    <%end%> <%= link_to 'Lägg till fler underkategorier?', settings_albums_path, target: "blank" %>
    <%end%>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %> - \ No newline at end of file + diff --git a/app/views/albums/_links.html.erb b/app/views/albums/_links.html.erb index b82851a1d..2f1132e5e 100644 --- a/app/views/albums/_links.html.erb +++ b/app/views/albums/_links.html.erb @@ -1,4 +1,4 @@ -<% if current_user.has_role?(:galleri, :edit) %> +<% if can?(:manage,Album) %> <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Lägg till bilder"), upload_images_album_path(@album), class: "btn-u btn-u-small" %> <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Redigera"), edit_album_path(@album), class: "btn-u btn-u-small" %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/albums/edit.html.erb b/app/views/albums/edit.html.erb index af4e9ff31..5c0d237c0 100644 --- a/app/views/albums/edit.html.erb +++ b/app/views/albums/edit.html.erb @@ -1,7 +1,7 @@
    - <%= label_tag 'Redigera album',nil, :class => 'reg-header'%>
    + <%= label_tag 'Redigera album',nil, class: 'reg-header'%>
    <% if @album.title %> <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa album"), @album,class: 'btn btn-u' %> @@ -23,7 +23,7 @@ <%= select_tag :image_category, options_from_collection_for_select(@album.subcategories,:id,:text), include_blank: true, - :class => " listBox"%>

    + class: " listBox"%>

    <%=submit_tag 'Byt kategori',class: "btn btn-u"%>
      <%for @image in @album.images%> @@ -38,4 +38,4 @@
    <%end-%>
    -
    \ No newline at end of file +
    diff --git a/app/views/albums/new.html.erb b/app/views/albums/new.html.erb index db63d52a3..94777add2 100644 --- a/app/views/albums/new.html.erb +++ b/app/views/albums/new.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Nytt album',nil, :class => 'reg-header'%> + <%= label_tag 'Nytt album',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa album', @album %>
    <%= link_to 'Tillbaka', :back %>
    -
    \ No newline at end of file +
    diff --git a/app/views/albums/upload_images.html.erb b/app/views/albums/upload_images.html.erb index ab9d5092e..bc51be19c 100644 --- a/app/views/albums/upload_images.html.erb +++ b/app/views/albums/upload_images.html.erb @@ -1,7 +1,7 @@
    - <%= label_tag 'Lägg till bilder i '+@album.title,nil, :class => 'reg-header'%> + <%= label_tag 'Lägg till bilder i '+@album.title,nil, class: 'reg-header'%> <%= form_for(@album,url: upload_images_album_path(@album), html: {multipart: true}) do |f| %> <% if @album.errors.any? %>
    @@ -15,17 +15,17 @@ <% end %>
    - <%= f.label 'Underkategori', :class => 'reg-label'%> + <%= f.label 'Underkategori', class: 'reg-label'%>
    - <%= select_tag :subcategory_id, options_from_collection_for_select(@album.subcategories,:id,:text,@subcategory),{:class => 'form-control',include_blank: true}%> + <%= select_tag :subcategory_id, options_from_collection_for_select(@album.subcategories,:id,:text,@subcategory),{class: 'form-control',include_blank: true}%>
    - <%= f.label 'Bilder', :class => 'reg-label'%> + <%= f.label 'Bilder', class: 'reg-label'%>
    <%= file_field_tag "fotos[]", type: :file, multiple: true %>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %> @@ -36,4 +36,4 @@
    <% # jquery image template # %> - \ No newline at end of file + diff --git a/app/views/cafe_works/_authorization.html.erb b/app/views/cafe_works/_authorization.html.erb index cdbdd9409..3112fda79 100644 --- a/app/views/cafe_works/_authorization.html.erb +++ b/app/views/cafe_works/_authorization.html.erb @@ -1,5 +1,5 @@ -<%=form_for(@cwork, url: authorize_cafe_work_url(@cwork), remote: true ) do |f|%> - <%= f.label 'Kod', :class => 'reg-label'%> +<%=form_for(@cafe_work, url: authorize_cafe_work_url(@cafe_work), remote: true ) do |f|%> + <%= f.label 'Kod', class: 'reg-label'%>
    <%= f.text_field :access_code, value: nil, class: 'form-control'%> @@ -7,4 +7,4 @@
    <%= f.submit "Auktorisera",class: 'btn-u pull-right' %>
    -<%end%> \ No newline at end of file +<%end%> diff --git a/app/views/contacts/_form.html.erb b/app/views/contacts/_form.html.erb index 78a80d1d3..d8cb0eb4f 100644 --- a/app/views/contacts/_form.html.erb +++ b/app/views/contacts/_form.html.erb @@ -9,25 +9,25 @@
    <% end %> - <%= f.label 'Titel', :class => "reg-label"%> + <%= f.label 'Titel', class: "reg-label"%>
    - <%= f.text_field :name, :class => 'form-control',:placeholder => 'Titel'%> + <%= f.text_field :name, class: 'form-control',:placeholder => 'Titel'%>
    - <%= f.label 'Beskrivning', :class => 'reg-label'%> + <%= f.label 'Beskrivning', class: 'reg-label'%>
    - <%= f.text_area :text, :class => 'form-control',:placeholder => 'Varför ska man kontakta er?',:size => "45x4" %> + <%= f.text_area :text, class: 'form-control',:placeholder => 'Varför ska man kontakta er?',:size => "45x4" %>
    - <%= f.label 'E-post', :class => 'reg-label'%> + <%= f.label 'E-post', class: 'reg-label'%>
    Delas inte ut till någon. - <%= f.text_field :email, :class => 'form-control',:placeholder => 'Epost',:autocomplete => 'off' %> + <%= f.text_field :email, class: 'form-control',:placeholder => 'Epost',:autocomplete => 'off' %>
    - <%= f.label 'Publik?', :class => 'reg-label'%> + <%= f.label 'Publik?', class: 'reg-label'%>
    - <%= f.check_box :public, :class => 'form-control'%> + <%= f.check_box :public, class: 'form-control'%> Innebär att även de som inte är inloggade kan kontakta.
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %> diff --git a/app/views/contacts/edit.html.erb b/app/views/contacts/edit.html.erb index e6689e566..216fa33e7 100644 --- a/app/views/contacts/edit.html.erb +++ b/app/views/contacts/edit.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag "Redigera kontakt",nil, :class => 'reg-header'%> + <%= label_tag "Redigera kontakt",nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), @contact, method: :delete, data: {confirm: "Är du säker?"}, class: "btn-u btn-u-small" %>
    <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file +
    diff --git a/app/views/contacts/new.html.erb b/app/views/contacts/new.html.erb index 9569fbcf4..eb92b7911 100644 --- a/app/views/contacts/new.html.erb +++ b/app/views/contacts/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny kontakt',nil, :class => 'reg-header'%> + <%= label_tag 'Ny kontakt',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file +
    diff --git a/app/views/contacts/show.html.erb b/app/views/contacts/show.html.erb index 131464b0c..8abaca833 100644 --- a/app/views/contacts/show.html.erb +++ b/app/views/contacts/show.html.erb @@ -17,18 +17,18 @@
    <%= label_tag "E-post"%>
    - <%= text_field_tag :email, nil, :required => true, :pattern => '[^@]+@[^@]+\.[a-zA-Z]{2,6}',:class => 'form-control' %>
    + <%= text_field_tag :email, nil, :required => true, :pattern => '[^@]+@[^@]+\.[a-zA-Z]{2,6}',class: 'form-control' %>
    <%= label_tag "Meddelande"%>
    - <%= text_area_tag :msg,nil, :required => true , :class => 'form-control', :size => '100x10'%>
    + <%= text_area_tag :msg,nil, :required => true , class: 'form-control', :size => '100x10'%>
    - <%= submit_tag "Skicka", :class => 'form-control btn-u btn-u-orange'%> + <%= submit_tag "Skicka", class: 'form-control btn-u btn-u-orange'%>
    <% end %> - \ No newline at end of file + diff --git a/app/views/councils/_form.html.erb b/app/views/councils/_form.html.erb index a61ca2800..9814c1f0a 100644 --- a/app/views/councils/_form.html.erb +++ b/app/views/councils/_form.html.erb @@ -1,45 +1,39 @@ -<%= form_for(@council, :html => { :autocomplete => 'off' }) do |f| %> - <% if @council.errors.any? %> -
    -

    <%= pluralize(@council.errors.count, "error") %> gör att utskottet inte kan sparas:

    - -
    - <% end %> - <%= f.label 'Titel', :class => "reg-label"%> -
    - <%= f.text_field :title, :class => 'form-control',:placeholder => 'Titel'%> -
    - <%= f.label 'Beskrivning', :class => 'reg-label'%> -
    - <%= f.text_area :description, :class => 'form-control',:placeholder => 'Beskrivning' %> -
    - <%= f.label 'Url - små bokstäver, a-z, till exempel "pryl"', :class => 'reg-label'%> -
    - <%= f.text_field :url, :class => 'form-control',:placeholder => 'Url',:autocomplete => 'off' %> -
    - <%= f.label 'Publik?', :class => 'reg-label'%> -
    - Innebär att även de som inte är inloggade kan
    - läsa om utskottet. - <%= f.check_box :public, :class => 'form-control'%> -
    - <%if @council.posts.count > 0 %> - <%= f.label 'Ordförande', :class => 'reg-label'%> -
    - <%= f.select :president, options_for_select(@council.posts.collect{ |r| [r.title, r.id] },selected: @council.president),{include_blank: true},:class => 'form-control'%> -
    - <%elsif @council.new_record? == false%> - Detta utskott har inga poster, lägg till en post och välj sedan här vilken post som är utskottets ordförande. -
    - <%end%> -
    - <%= f.submit "Spara",:class => 'btn-u pull-right btn-u-small' %> - <%if @council.id.nil? == false%> - <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), @council, method: :delete, data: {confirm: "Är du säker?"}, class: "btn-u btn-u-small" %> - <%end%> -
    -<% end %> \ No newline at end of file +<%= form_for(@council) do |f| %> + <%= render 'shared/form_errors', current: @council %> + <%= f.label 'Titel', class: "reg-label" %> +
    + <%= f.text_field :title, class: 'form-control', placeholder: 'Titel' %> +
    + <%= f.label 'Beskrivning', class: 'reg-label' %> +
    + <%= f.text_area :description, class: 'form-control', placeholder: 'Beskrivning', size: '40x5' %> +
    + <%= f.label 'Url - små bokstäver, a-z, till exempel "pryl"', class: 'reg-label' %> +
    + <%= f.text_field :url, class: 'form-control', placeholder: 'Url' %> +
    + <%= f.label 'Publik?', class: 'reg-label' %> +
    + Innebär att även de som inte är inloggade kan
    + läsa om utskottet. + <%= f.check_box :public, class: 'form-control' %> +
    + <% if @council.posts.count > 0 %> + <%= f.label 'Ordförande', class: 'reg-label' %> +
    + <%= f.collection_select(:president_id, @council.posts, :id, :title, include_blank: true, + class: 'form-control')%> +
    + <% elsif not @council.new_record? %> + Detta utskott har inga poster, lägg till en post och välj sedan här vilken post som är utskottets ordförande. +
    + <% end %> +
    + <%= f.submit "Spara", class: 'btn-u pull-right btn-u-small' %> + <% if not @council.new_record? %> + <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), + @council, method: :delete, data: {confirm: "Är du säker?"}, + class: "btn-u btn-u-small" %> + <% end %> +
    +<% end %> diff --git a/app/views/councils/_menu.html.erb b/app/views/councils/_menu.html.erb new file mode 100644 index 000000000..b14868806 --- /dev/null +++ b/app/views/councils/_menu.html.erb @@ -0,0 +1,8 @@ + diff --git a/app/views/councils/edit.html.erb b/app/views/councils/edit.html.erb index 2be53f8fa..b45001083 100644 --- a/app/views/councils/edit.html.erb +++ b/app/views/councils/edit.html.erb @@ -1,22 +1,18 @@
    -
    -
    - <%= label_tag 'Redigera utskott',nil, :class => 'reg-header'%> - <%= render 'form'%> -
    - <%= link_to 'Lägg till post', new_council_post_path(@council),class:"btn-u" %> <%= link_to 'Visa poster', council_posts_path(@council),class:"btn-u" %> - <%= link_to 'Redigera sida', council_page_path(@council),class:"btn-u" %> -
    - <%= link_to 'Visa utskott', @council,class:"btn-u" %> -
    - <%if @council.page%> -
    - <%if @contact %> - <%= label_tag 'Redigera kontakt',nil, :class => 'reg-header'%> - <%=render partial: "contacts/form",object: @contact%> - <%end%> -
    - <%end%> -
    -
    - \ No newline at end of file +
    +
    + <%= label_tag 'Redigera utskott', nil, class: 'reg-header' %> + <%= render 'form' %> +
    + <%= link_to 'Lägg till post', new_council_post_path(@council), class: "btn-u" %> + <%= link_to 'Visa poster', council_posts_path(@council), class: "btn-u" %> + <% if @council.page.present?%> + <%= link_to 'Redigera sida', page_path(@page), class: "btn-u" %> + <% end %> +
    + <%= link_to 'Visa utskott', @council, class: "btn-u" %> +
    + +
    + + diff --git a/app/views/councils/new.html.erb b/app/views/councils/new.html.erb index 9569fbcf4..eb92b7911 100644 --- a/app/views/councils/new.html.erb +++ b/app/views/councils/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny kontakt',nil, :class => 'reg-header'%> + <%= label_tag 'Ny kontakt',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/councils/show.html.erb b/app/views/councils/show.html.erb index 55286adf9..33abd0d81 100644 --- a/app/views/councils/show.html.erb +++ b/app/views/councils/show.html.erb @@ -1,8 +1,20 @@ <% title('Utskott') %>
    - <%if can? :edit, @council %> - <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Redigera"), edit_council_path(@council), class: "btn-u btn-u-small"%> - <%end%> + <% if can? :edit, @council %> + <%= link_to(fa_icon('edit') + ' Redigera', edit_council_path(@council), class: "btn-u btn-u-small") %> + <% end %> +
    +
    +
    + <% if @page.present? %> +
    + <%= render @page %> +
    + <% end %> + <% if @council.posts.present? %> +
    + <%= render 'posts/table', collection: @council.posts %> +
    + <% end %> +
    -
    -<%=render partial: "pages/main"%> diff --git a/app/views/councils/show.json.jbuilder b/app/views/councils/show.json.jbuilder deleted file mode 100644 index 1949648a2..000000000 --- a/app/views/councils/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @page, :id, :created_at, :updated_at diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index de50d98b4..4f7b02af2 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,53 +1,53 @@
    - <%= form_for(resource, :as => resource_name, :url => update_user_registration_path(resource), :html => { :method => :patch,:class => "reg-page" }) do |f| %> + <%= form_for(resource, :as => resource_name, :url => update_user_registration_path(resource), :html => { :method => :patch,class: "reg-page" }) do |f| %> - <%= f.label 'Redigera användare', :class => 'reg-header'%>
    - <%= f.label 'Användarnamn', :class => 'reg-label'%> + <%= f.label 'Redigera användare', class: 'reg-header'%>
    + <%= f.label 'Användarnamn', class: 'reg-label'%>
    <%= fa_icon('user')%> - <%= f.text_field :username, :class => 'form-control',:placeholder => 'Användarnamn'%> + <%= f.text_field :username, class: 'form-control',:placeholder => 'Användarnamn'%>
    - <%= f.label 'E-post', :class => 'reg-label'%> + <%= f.label 'E-post', class: 'reg-label'%>
    <%= fa_icon('envelope')%> - <%= f.email_field :email, :class => 'form-control',:placeholder => 'E-postadress' %> + <%= f.email_field :email, class: 'form-control',:placeholder => 'E-postadress' %>
    - <%= f.label 'Fyll i nytt lösenord för att byta.', :class => 'reg-header'%>
    - <%= f.label 'Nytt lösenord', :class => 'reg-label'%> + <%= f.label 'Fyll i nytt lösenord för att byta.', class: 'reg-header'%>
    + <%= f.label 'Nytt lösenord', class: 'reg-label'%>
    <%= fa_icon('lock')%> - <%= f.password_field :password, :class => 'form-control',:placeholder => 'Nytt lösenord',:autocomplete => 'off' %> + <%= f.password_field :password, class: 'form-control',:placeholder => 'Nytt lösenord',:autocomplete => 'off' %>
    - <%= f.label 'Bekräfta lösenord', :class => 'reg-label'%> + <%= f.label 'Bekräfta lösenord', class: 'reg-label'%>
    <%= fa_icon('lock')%> - <%= f.password_field :password_confirmation, :class => 'form-control',:placeholder => 'Bekräfta lösenord' %> + <%= f.password_field :password_confirmation, class: 'form-control',:placeholder => 'Bekräfta lösenord' %>
    - <%= f.label 'Bekräfta ändringar med nuvarande lösenord', :class => 'reg-header'%> + <%= f.label 'Bekräfta ändringar med nuvarande lösenord', class: 'reg-header'%>
    <%= fa_icon('lock')%> - <%= f.password_field :current_password, :class => 'form-control',:placeholder => 'Nuvarande lösenord' %> + <%= f.password_field :current_password, class: 'form-control',:placeholder => 'Nuvarande lösenord' %>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %>

    - <%= form_for(resource, :as => resource_name, :url => admin_destroy_user_path(resource), :html => { :method => :delete,:class => "reg-page" }) do |f| %> + <%= form_for(resource, :as => resource_name, :url => admin_destroy_user_path(resource), :html => { :method => :delete,class: "reg-page" }) do |f| %> <%= devise_error_messages! %> - <%= f.label 'Ta bort användare', :class => 'reg-header'%>
    + <%= f.label 'Ta bort användare', class: 'reg-header'%>
    <%= fa_icon('lock')%> - <%= f.password_field :currrent_password, :class => 'form-control',:placeholder => 'Nuvarande lösenord'%> + <%= f.password_field :currrent_password, class: 'form-control',:placeholder => 'Nuvarande lösenord'%>
    - <%= f.submit "Ta bort mitt konto", :data => { :confirm => "Är du säker?" },:class => 'btn-u pull-right'%> + <%= f.submit "Ta bort mitt konto", :data => { :confirm => "Är du säker?" },class: 'btn-u pull-right'%>
    <%= link_to "Tillbaka", :back %> <% end %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 5993a4773..f79272552 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,39 +1,43 @@
    -
    - <%= devise_error_messages! %> -
    - <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => "reg-page", autofill: 'off'}, options: {autocomplete: 'off'}) do |f| %> - - <%= f.label 'Registrera ny användare', :class => 'reg-header'%>
    - -
    - <%= fa_icon('user')%> - <%= f.text_field :username, :class => 'form-control',:placeholder => 'Användarnamn', :autofocus => true%> -
    -
    - <%= fa_icon('envelope')%> - <%= f.email_field :email, :class => 'form-control',:placeholder => 'E-postadress' %> -
    -
    - <%= fa_icon('lock')%> - <%= f.password_field :password, :class => 'form-control',:placeholder => 'Nytt lösenord'%> -
    -
    - <%= fa_icon('lock')%> - <%= f.password_field :password_confirmation, :class => 'form-control',:placeholder => 'Bekräfta lösenord' %> -
    - <%= f.label 'Personnummer', :class => 'reg-label'%>
    - För att kolla medlemskap - sparas ej. -
    - <%= fa_icon('bolt')%> - <%= text_field_tag :civic, nil, :class => 'form-control',:placeholder => 'Personnummer (10 siffor i följd)'%> -
    -
    - <%= f.submit "Registrera",:class => 'btn-u pull-right' %> -
    - <%= render "devise/shared/links" %> - <% end %> -
    -
    -
    +
    + <%= devise_error_messages! %> +
    + <%= form_for(resource, as: resource_name, url: registration_path(resource_name), + html: {class: "reg-page", autofill: 'off'}, + options: {autocomplete: 'off'}) do |f| %> + + <%= f.label t('devise.sign_up'), class: 'reg-header' %>
    + +
    + <%= fa_icon('user') %> + <%= f.text_field :username, class: 'form-control', + placeholder: :username, autofocus: true %> +
    +
    + <%= fa_icon('envelope') %> + <%= f.email_field :email, class: 'form-control', placeholder: :email %> +
    +
    + <%= fa_icon('lock') %> + <%= f.password_field :password, class: 'form-control', placeholder: :password %> +
    +
    + <%= fa_icon('lock') %> + <%= f.password_field :password_confirmation, class: 'form-control', + placeholder: :password_confirmation %> +
    + <%= t('registation.civic_check') %> +
    + <%= fa_icon('bolt') %> + <%= text_field_tag :civic, nil, class: 'form-control', + placeholder: t('attributes.civic') %> +
    +
    + <%= f.submit nil, class: 'btn-u pull-right' %> +
    + <%= render "devise/shared/links" %> + <% end %> +
    +
    +
    diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index af0dc8ef1..e5ef7ca7d 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,39 +1,39 @@
    -
    -
    - <%= form_for(resource,:html => {:class => "reg-page"}, :as => resource_name, :url => session_path(resource_name)) do |f| %> - - <%= f.label 'Logga in', :class => 'reg-header'%>
    - -
    - <%= fa_icon('user')%> - <%= f.text_field :username, :autofocus => true, :class => 'form-control',:placeholder => 'Användarnamn'%> -
    -
    - <%= fa_icon('lock')%> - <%= f.password_field :password, :class => 'form-control',:placeholder => 'Lösenord' %> -
    -
    -
    - <% if devise_mapping.rememberable? -%> -
    <%= f.check_box :remember_me %> <%= f.label 'Kom ihåg?' %>
    - <% end -%> -
    -
    - <%= f.submit "Logga in",:class => 'btn-u pull-right' %> -
    -
    - -
    - <%= render "devise/shared/links" %> -
    - <% end %> -
    -
    +
    +
    + <%= form_for(resource, as: resource_name, + url: session_path(resource_name)) do |f| %> + <%= f.label t('devise.sign_in'), class: 'reg-header' %>
    - - - - -
    -
    \ No newline at end of file +
    + <%= fa_icon('user') %> + <%= f.text_field :username, autofocus: true, class: 'form-control', + placeholder: :username %> +
    +
    + <%= fa_icon('lock') %> + <%= f.password_field :password, class: 'form-control', + placeholder: :password %> +
    +
    +
    + <% if devise_mapping.rememberable? -%> +
    <%= f.check_box :remember_me %> + <%= f.label t('devise.remember_me') %>
    + <% end -%> +
    +
    + <%= f.submit t('devise.sign_in'), class: 'btn-u pull-right' %> +
    +
    + +
    + <%= render "devise/shared/links" %> +
    + <% end %> +
    +
    + + + + diff --git a/app/views/devise/shared/_links.erb b/app/views/devise/shared/_links.erb index cdfa2b172..959950118 100644 --- a/app/views/devise/shared/_links.erb +++ b/app/views/devise/shared/_links.erb @@ -1,25 +1,25 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Logga in", new_session_path(resource_name) %>
    + <%= link_to t('devise.sign_in'), new_session_path(resource_name) %>
    <% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Registrera", new_registration_path(resource_name) %>
    + <%= link_to t('devise.sign_up'), new_registration_path(resource_name) %>
    <% end -%> <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Glömt lösenord?", new_password_path(resource_name) %>
    + <%= link_to t('devise.password_forgotten'), new_password_path(resource_name) %>
    <% end -%> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Fick inte någon bekräftelse?", new_confirmation_path(resource_name) %>
    + <%= link_to t('devise.not_receive_confirm'), new_confirmation_path(resource_name) %>
    <% end -%> <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> - <%= link_to "Fick ingen information för att låsa upp?", new_unlock_path(resource_name) %>
    + <%= link_to t('devise.not_receive_unlock'), new_unlock_path(resource_name) %>
    <% end -%> <%- if devise_mapping.omniauthable? %> <%- resource_class.omniauth_providers.each do |provider| %> - <%= link_to "Logga in med #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
    + <%= link_to %(#{t('devise.sign_in_with')} #{provider.to_s.titleize}), omniauth_authorize_path(resource_name, provider) %>
    <% end -%> <% end -%> diff --git a/app/views/documents/_form.html.erb b/app/views/documents/_form.html.erb index b65ccc59f..8c34d72b2 100644 --- a/app/views/documents/_form.html.erb +++ b/app/views/documents/_form.html.erb @@ -9,28 +9,28 @@ <% end %> - <%= f.label 'Titel', :class => "reg-label"%> + <%= f.label 'Titel', class: "reg-label"%>
    - <%= f.text_field :title, :class => 'form-control',:placeholder => 'Titel'%> + <%= f.text_field :title, class: 'form-control',:placeholder => 'Titel'%>
    - <%= f.label 'Kategori', :class => 'reg-label'%> + <%= f.label 'Kategori', class: 'reg-label'%>
    - <%= f.select :category,options_for_select(["Styrdokument", "Protokoll", "Sektionsmöten", "Övrigt"],@dokument.category), :class => 'form-control'%> + <%= f.select :category,options_for_select(["Styrdokument", "Protokoll", "Sektionsmöten", "Övrigt"],@dokument.category), class: 'form-control'%>
    - <%= f.label 'PDF', :class => 'reg-label'%> + <%= f.label 'PDF', class: 'reg-label'%>
    <%if @dokument.pdf_file_name.blank?%> - <%= f.file_field :pdf, :class => 'form-control'%> + <%= f.file_field :pdf, class: 'form-control'%> <%else%> <%=@dokument.pdf_file_name%> <%end%>
    - <%= f.label 'Publik?', :class => 'reg-label'%> + <%= f.label 'Publik?', class: 'reg-label'%>
    - <%= f.check_box :public, :class => 'form-control'%> + <%= f.check_box :public, class: 'form-control'%> Innebär att även de som inte är inloggade kan se dokument.
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    - <% end %> \ No newline at end of file + <% end %> diff --git a/app/views/documents/edit.html.erb b/app/views/documents/edit.html.erb index 803c7705d..209a0f9f7 100644 --- a/app/views/documents/edit.html.erb +++ b/app/views/documents/edit.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag "Redigera dokument",nil, :class => 'reg-header'%> + <%= label_tag "Redigera dokument",nil, class: 'reg-header'%> <%=render partial: "form"%> <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), @dokument, method: :delete, data: {confirm: "Är du säker?"}, class: "btn-u btn-u-small" %>
    <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/documents/new.html.erb b/app/views/documents/new.html.erb index 69c152902..84a7c3934 100644 --- a/app/views/documents/new.html.erb +++ b/app/views/documents/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Nytt dokument',nil, :class => 'reg-header'%> + <%= label_tag 'Nytt dokument',nil, class: 'reg-header'%> <%=render partial: "form"%> <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/election/nominations/_form.html.erb b/app/views/election/nominations/_form.html.erb deleted file mode 100644 index 856e34d1f..000000000 --- a/app/views/election/nominations/_form.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<%= form_for([:election,nomination], remote: true) do |f| %> - <%= render 'shared/form_errors', current: @nomination %> - <%= f.label 'Namn', :class => 'reg-label' %> -
    - <%= f.text_field :name, :class => 'form-control' %> -
    - <%= f.label 'E-post', :class => 'reg-label' %> -
    - <%= f.email_field :email, :class => 'form-control' %> -
    -
    - <%= f.label 'Post', :class => 'reg-label' %>
    - <%= f.select :post_id, - options_from_collection_for_select(election.current_posts, :id, :title, params[:post].to_i), - include_blank: true, - :class => "form-control listBox" %> -
    - <%= f.label 'Motivering', :class => 'reg-label' %>
    - Frivillig - den nominerade kan se den i ett mejl. -
    - <%= f.text_area :motivation, :class => 'form-control' %> -
    - -
    - <%= f.submit "Spara", :class => 'btn-u' %> -
    -<% end %> \ No newline at end of file diff --git a/app/views/election/nominations/create.js.erb b/app/views/election/nominations/create.js.erb deleted file mode 100644 index 51be3fbba..000000000 --- a/app/views/election/nominations/create.js.erb +++ /dev/null @@ -1,6 +0,0 @@ -<% if @saved == true %> -$('#nomination-form').fadeOut('slow'); -$('#status').hide().html("

    Tack för din nominering!

    ").fadeIn('slow'); -<%else%> -$('#status').hide().html("

    Namn och e-post måste fyllas i och en post måste väljas.

    ").fadeIn('slow'); -<%end%> \ No newline at end of file diff --git a/app/views/election_mailer/candidate_email.html.erb b/app/views/election_mailer/candidate_email.html.erb index d07ebf36b..704bafd63 100644 --- a/app/views/election_mailer/candidate_email.html.erb +++ b/app/views/election_mailer/candidate_email.html.erb @@ -10,9 +10,9 @@ <%if (@candidate.election.candidate_mail)%> <%= simple_format(@candidate.election.candidate_mail)%> <%end%> - <%if (@candidate.post.styrelse)%> + <%if @candidate.post.styrelse && @candidate.election.mail_styrelse_link.present?%> <%=link_to(@candidate.election.mail_styrelse_link,@candidate.election.mail_styrelse_link)%>

    - <%else%> + <%elsif @candidate.election.mail_link.present?%> <%=link_to(@candidate.election.mail_link,@candidate.election.mail_link)%>

    <%end%> <%else%> @@ -24,4 +24,4 @@

    Mvh,
    Valberedningen

    - \ No newline at end of file + diff --git a/app/views/elections/_election.html.erb b/app/views/elections/_election.html.erb new file mode 100644 index 000000000..903ce704b --- /dev/null +++ b/app/views/elections/_election.html.erb @@ -0,0 +1,36 @@ +
    +

    <%= election.title %>

    + +

    <%= simple_format(election.description) %>


    + +

    <%= simple_format(election.status_text) %>

    + <%= render "countdown" %> + +
    + <%= link_to(model_name(Nomination), new_nominations_path, class: "btn btn-election") %> +
    +
    + <%= link_to(model_name(Candidate), candidates_path, class: "btn btn-election") %> +
    + +
    +

    <%= election.view_status == :before ? t('elections.posts_before') : t('elections.posts_during') %>

    + <%= render "posttab", grid: @grid_election, election: election %> + + <% if election.view_status == :after %> +

    <%= t('elections.posts_after') %>

    + <%= render "posttab", grid: @grid_termins, election: election %> + <% end %> +
    + +

    <%= t('elections.get_in_touch') %> + <%= render partial: "contacts/kontakt", locals: {name: 'Spindelmän'} %>

    +
    +
    diff --git a/app/views/elections/_index.html.erb b/app/views/elections/_index.html.erb deleted file mode 100644 index 79ae3e798..000000000 --- a/app/views/elections/_index.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -
    -

    <%= @election.title %>

    - -

    <%= simple_format(@election.description) %>


    - -

    <%= simple_format(@election.status_text) %>

    - <%= render "countdown" %> - -
    - <%= link_to("Nominering", election_nominations_path, class: "btn btn-election") %> -
    -
    - <%= link_to("Kandidatur", election_candidates_path, class: "btn btn-election") %> -
    - -
    - <% if @election.view_status == 1%> -

    Poster som kommer kunna sökas

    - <%= render "posttab", grid: @grid_election %> -

    Orangefärgade fält innebär att posten sitter i styrelsen.

    - <% elsif @election.view_status == 2%> -

    Poster som kan sökas

    - <%= render "posttab", grid: @grid_election %> -

    Orangefärgade fält innebär att posten sitter i styrelsen.

    - <% elsif @election.view_status == 3%> -

    Poster som går att söka

    - <%= render "posttab", grid: @grid_election %> -

    Grönfärgade fält innebär att posten väljs av studierådet.

    -

    Poster som inte går att söka längre

    - <%= render "posttab", grid: @grid_termins %> -

    Orangefärgade fält innebär att posten sitter i styrelsen.

    - <%end%> -
    - -

    Ser något konstigt ut eller blir det fel? Hör av dig - till <%= render partial: "contacts/kontakt", locals: {name: 'Spindelmän'} %>

    -
    -
    diff --git a/app/views/elections/_posttab.html.erb b/app/views/elections/_posttab.html.erb index b1d937278..2d1d5cfcd 100644 --- a/app/views/elections/_posttab.html.erb +++ b/app/views/elections/_posttab.html.erb @@ -13,12 +13,12 @@ post.printLimit end g.column name: "Utskott", attribute: "council_id",filter: false do |post| - post.council.title + post.council end g.column name: "Väljs av", attribute: "elected_by",filter: false - if (@election.view_status != 1) + if (election.view_status != 1) g.column name: "Kandidater", filter: false do |post| - @election.candidate_count(post) + election.candidate_count(post) end end end -%> diff --git a/app/views/election/candidates/_candidate_table.html.erb b/app/views/elections/candidates/_candidate_table.html.erb similarity index 100% rename from app/views/election/candidates/_candidate_table.html.erb rename to app/views/elections/candidates/_candidate_table.html.erb diff --git a/app/views/election/candidates/_form.html.erb b/app/views/elections/candidates/_form.html.erb similarity index 53% rename from app/views/election/candidates/_form.html.erb rename to app/views/elections/candidates/_form.html.erb index 35423e703..c9bd0de22 100644 --- a/app/views/election/candidates/_form.html.erb +++ b/app/views/elections/candidates/_form.html.erb @@ -2,37 +2,37 @@ <%= render 'shared/form_errors',current: @candidate %> Uppgifter ifylls i <%= link_to('profilen', edit_profile_path(current_user.profile)) %>.
    - <%= f.label :name, :class => 'reg-label' %> & <%= f.label :lastname, :class => 'reg-label' %> + <%= f.label :name, class: 'reg-label' %> & <%= f.label :lastname, class: 'reg-label' %>
    -
    <%= f.text_field :name, :class => 'form-control', placeholder: "Förnamn" %>
    -
    <%= f.text_field :lastname, :class => 'form-control', placeholder: "Efternamn" %>
    +
    <%= f.text_field :name, class: 'form-control', placeholder: "Förnamn" %>
    +
    <%= f.text_field :lastname, class: 'form-control', placeholder: "Efternamn" %>
    - <%= f.label :email, :class => 'reg-label' %> & <%= f.label :phone, :class => 'reg-label' %> + <%= f.label :email, class: 'reg-label' %> & <%= f.label :phone, class: 'reg-label' %>
    -
    <%= f.email_field :email, :class => 'form-control', placeholder: "E-post" %>
    -
    <%= f.phone_field :phone, :class => 'form-control', placeholder: "Telefon" %>
    +
    <%= f.email_field :email, class: 'form-control', placeholder: "E-post" %>
    +
    <%= f.phone_field :phone, class: 'form-control', placeholder: "Telefon" %>
    - <%= f.label :stil_id, :class => 'reg-label' %> + <%= f.label :stil_id, class: 'reg-label' %>
    <%= f.text_field :stil_id, class: 'form-control',placeholder: 'Stil-ID' %>
    - <%= f.label 'Post', :class => 'reg-label' %>
    + <%= f.label 'Post', class: 'reg-label' %>
    <% if @candidate.new_record?%> <%= f.select :post_id, options_from_collection_for_select(@election.current_posts, :id, :title, @candidate.post_id), include_blank: true, - :class => "form-control listBox" %> + class: "form-control listBox" %> <%else%>

    <%= @candidate.post.title%>

    Det går inte att byta post, har du valt fel får du ta bort denna kandidaturen och skapa en ny.

    <%end%>
    - <%= f.submit :class => 'btn btn-u' %> + <%= f.submit class: 'btn btn-u' %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/election/candidates/candidate.html.erb b/app/views/elections/candidates/candidate.html.erb similarity index 90% rename from app/views/election/candidates/candidate.html.erb rename to app/views/elections/candidates/candidate.html.erb index 2db397487..5f0a548a2 100644 --- a/app/views/election/candidates/candidate.html.erb +++ b/app/views/elections/candidates/candidate.html.erb @@ -10,7 +10,7 @@
    -

    <%= label_tag 'Kandidera!', nil, :class => 'reg-header' %>

    +

    <%= label_tag 'Kandidera!', nil, class: 'reg-header' %>

    <% if @done %>

    Tack för din kandidering

    Det kanske finns en post till att söka?

    @@ -25,12 +25,12 @@
    <% elsif @before %>
    -

    <%= label_tag 'Kandideringar öppnar: ' + @valet.start.to_date.to_s, nil, :class => 'reg-header' %>

    +

    <%= label_tag 'Kandideringar öppnar: ' + @valet.start.to_date.to_s, nil, class: 'reg-header' %>

    <%= link_to image_tag("layout/f.svg", class: "val-logo"), elections_path %>
    <% else %>
    -

    <%= label_tag 'Kandideringar har stängt.', nil, :class => 'reg-header' %>

    +

    <%= label_tag 'Kandideringar har stängt.', nil, class: 'reg-header' %>

    Du kan inte längre kandidera på nya poster eller ändra dina kandidaturer.

    <%= link_to image_tag("layout/f.svg", class: "val-logo"), elections_path %> <%= grid(@candidates_grid) do |g| @@ -48,4 +48,4 @@ end end -%>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/election/candidates/index.html.erb b/app/views/elections/candidates/index.html.erb similarity index 91% rename from app/views/election/candidates/index.html.erb rename to app/views/elections/candidates/index.html.erb index 2d03c7c24..1fb3a3fa6 100644 --- a/app/views/election/candidates/index.html.erb +++ b/app/views/elections/candidates/index.html.erb @@ -12,12 +12,12 @@
    <% elsif @election.view_status == 1 %>
    -

    <%= label_tag 'Kandideringar öppnar: ' + @election.start.to_date.to_s, nil, :class => 'reg-header' %>

    +

    <%= label_tag 'Kandideringar öppnar: ' + @election.start.to_date.to_s, nil, class: 'reg-header' %>

    <%= link_to image_tag("layout/f.svg", class: "val-logo"), elections_path %>
    <% elsif @election.view_status == 3 %>
    -

    <%= label_tag 'Kandideringar har stängt.', nil, :class => 'reg-header' %>

    +

    <%= label_tag 'Kandideringar har stängt.', nil, class: 'reg-header' %>

    Du kan inte längre kandidera på nya poster eller ändra dina kandidaturer.

    <%= link_to image_tag("layout/f.svg", class: "val-logo"), elections_path %> <%= grid(@candidates_grid) do |g| @@ -35,4 +35,4 @@ end end -%>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/election/candidates/new.html.erb b/app/views/elections/candidates/new.html.erb similarity index 75% rename from app/views/election/candidates/new.html.erb rename to app/views/elections/candidates/new.html.erb index f19e38612..1e6e2252f 100644 --- a/app/views/election/candidates/new.html.erb +++ b/app/views/elections/candidates/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny kandidatur',nil, :class => 'reg-header'%> + <%= label_tag 'Ny kandidatur',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka', election_candidates_path %>
    -
    \ No newline at end of file + diff --git a/app/views/election/candidates/show.html.erb b/app/views/elections/candidates/show.html.erb similarity index 82% rename from app/views/election/candidates/show.html.erb rename to app/views/elections/candidates/show.html.erb index cee0c5cdb..3bd41149c 100644 --- a/app/views/election/candidates/show.html.erb +++ b/app/views/elections/candidates/show.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Redigera kandidatur',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera kandidatur',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka', election_candidates_path,class: "btn-u btn-u-small" %> <%= link_to 'Ta bort', election_candidate_path(@candidate), method: :delete, class: "btn-u btn-u-small" %>
    -
    \ No newline at end of file + diff --git a/app/views/elections/index.html.erb b/app/views/elections/index.html.erb index 051f25bd6..eb112bee2 100644 --- a/app/views/elections/index.html.erb +++ b/app/views/elections/index.html.erb @@ -1,8 +1,8 @@ <% provide(:title, 'Val') %>
    - <% if @election %> - <%= render 'index' %> - <% if can? :edit, @election %> + <% if @election.present? %> + <%= render @election, election: @election %> + <% if can? :manage, @election %>
    <%= link_to("Redigera valet!", admin_election_path(@election), class: "btn btn-election ") %>
    <% end %> <% else %> diff --git a/app/views/elections/nominations/_form.html.erb b/app/views/elections/nominations/_form.html.erb new file mode 100644 index 000000000..6b2be0347 --- /dev/null +++ b/app/views/elections/nominations/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_for(nomination, remote: true) do |f| %> + <%= render 'shared/form_errors', current: nomination %> + <%= f.label :name, class: 'reg-label' %> +
    + <%= f.text_field :name, class: 'form-control' %> +
    + <%= f.label :email, class: 'reg-label' %> +
    + <%= f.email_field :email, class: 'form-control' %> +
    +
    + <%= f.label model_name(Post), class: 'reg-label' %>
    + <%= f.select :post, + options_from_collection_for_select(election.current_posts, :id, :title, params[:post].to_i), + include_blank: true, + class: "form-control listBox" %> +
    + <%= f.label :motivation, class: 'reg-label' %>
    + Frivillig - den nominerade kan se den i ett mejl. +
    + <%= f.text_area :motivation, class: 'form-control' %> +
    + +
    + <%= f.submit nil, id: 'nomination-submit', class: 'btn-u' %> +
    +<% end %> diff --git a/app/views/elections/nominations/create.js.erb b/app/views/elections/nominations/create.js.erb new file mode 100644 index 000000000..78082767e --- /dev/null +++ b/app/views/elections/nominations/create.js.erb @@ -0,0 +1,6 @@ +<% if @saved == true %> +$('#nomination-form').fadeOut('slow'); +$('#status').hide().html("

    <%=I18n.t('nomination.thank_you')%>

    ").fadeIn('slow'); +<%else%> +$('#status').hide().html("

    <%=@nomination.errors%>

    ").fadeIn('slow'); +<%end%> diff --git a/app/views/election/nominations/new.html.erb b/app/views/elections/nominations/new.html.erb similarity index 82% rename from app/views/election/nominations/new.html.erb rename to app/views/elections/nominations/new.html.erb index 666cb0a44..500f3c625 100644 --- a/app/views/election/nominations/new.html.erb +++ b/app/views/elections/nominations/new.html.erb @@ -1,5 +1,5 @@ <% provide(:title, 'Val') %> -<% if @election.view_status != 1 %> +<% if @election.view_status != :after %>
    @@ -16,13 +16,13 @@ <%= render 'form', election: @election, nomination: @nomination%>
    - <%= link_to 'Tillbaka', elections_path, class: "btn-u btn-u-small" %> + <%= link_to t('actions.back'), elections_path, class: "btn-u btn-u-small" %>
    <% else %>
    -

    <%= label_tag 'Nomineringar:', nil, :class => 'reg-header' %>

    +

    <%= label_tag models_name(Nomination), nil, class: 'reg-header' %>

    <%= render 'elections/countdown' %> <%= link_to image_tag("layout/f.svg", class: "val-logo"), elections_path %>
    diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb index 097e80266..2d1bf2f25 100644 --- a/app/views/events/_form.html.erb +++ b/app/views/events/_form.html.erb @@ -9,47 +9,47 @@ <% end %> - <%= f.label 'Titel', :class => 'reg-label'%> + <%= f.label 'Titel', class: 'reg-label'%>
    - <%= f.text_field :title, :class => 'form-control',:placeholder => 'Titel'%> + <%= f.text_field :title, class: 'form-control',:placeholder => 'Titel'%>
    - <%= f.label 'Beskrivning', :class => 'reg-label'%> + <%= f.label 'Beskrivning', class: 'reg-label'%>
    - <%= f.text_area :description, :class => 'form-control',:placeholder => 'Beskrivning' %> + <%= f.text_area :description, class: 'form-control',:placeholder => 'Beskrivning' %>
    - <%= f.label 'Plats', :class => 'reg-label'%> + <%= f.label 'Plats', class: 'reg-label'%>
    - <%= f.text_field :location, :class => 'form-control',:placeholder => 'Plats',:autocomplete => 'off' %> + <%= f.text_field :location, class: 'form-control',:placeholder => 'Plats',:autocomplete => 'off' %>
    - <%= f.label 'Visningsbild', :class => 'reg-label'%> + <%= f.label 'Visningsbild', class: 'reg-label'%>
    <% if @event.image_file_name != nil%> <%= image_tag(@event.image(:thumb))%> <% end %> - <%= f.file_field :image, :class => 'form-control' %> + <%= f.file_field :image, class: 'form-control' %>
    - <%= f.label 'Heldagsevent', :class => 'reg-label'%> + <%= f.label 'Heldagsevent', class: 'reg-label'%>
    - <%= f.check_box :all_day, :class => '' %> + <%= f.check_box :all_day, class: '' %>
    - <%= f.label 'Startar', :class => 'reg-label'%> + <%= f.label 'Startar', class: 'reg-label'%>
    - <%= f.datetime_select :starts_at, :minute_step => 15, :class => 'form-control' %> + <%= f.datetime_select :starts_at, :minute_step => 15, class: 'form-control' %>
    - <%= f.label 'Slutar', :class => 'reg-label'%> + <%= f.label 'Slutar', class: 'reg-label'%>
    - <%= f.datetime_select :ends_at, :minute_step => 15, :class => 'form-control' %> + <%= f.datetime_select :ends_at, :minute_step => 15, class: 'form-control' %>
    - <%= f.label 'Ansvarigt utskott', :class => 'reg-label'%> + <%= f.label 'Ansvarigt utskott', class: 'reg-label'%>
    <%= f.select :category, options_from_collection_for_select(@utskott,:title,:title,@event.category), include_blank: true, - :class => "form-control listBox"%> + class: "form-control listBox"%>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb index bffd68324..2468b6d9a 100644 --- a/app/views/events/edit.html.erb +++ b/app/views/events/edit.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Redigera event',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera event',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa event', @event %>
    <%= link_to 'Tillbaka', :back %>
    -
    \ No newline at end of file + diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb index 80e56bac7..d19d29aaa 100644 --- a/app/views/events/new.html.erb +++ b/app/views/events/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Lägg till event',nil, :class => 'reg-header'%> + <%= label_tag 'Lägg till event',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka', :back %>
    -
    \ No newline at end of file + diff --git a/app/views/faqs/edit.html.erb b/app/views/faqs/edit.html.erb index 24131bcd1..4651f21bf 100644 --- a/app/views/faqs/edit.html.erb +++ b/app/views/faqs/edit.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Redigera fråga',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera fråga',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till faq', faqs_path %>
    -
    \ No newline at end of file + diff --git a/app/views/faqs/new.html.erb b/app/views/faqs/new.html.erb index 1febda4e0..314170fd4 100644 --- a/app/views/faqs/new.html.erb +++ b/app/views/faqs/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny fråga',nil, :class => 'reg-header'%> + <%= label_tag 'Ny fråga',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till faq', faqs_path %>
    -
    \ No newline at end of file + diff --git a/app/views/images/_form.html.erb b/app/views/images/_form.html.erb index 21804abe4..36953af71 100644 --- a/app/views/images/_form.html.erb +++ b/app/views/images/_form.html.erb @@ -9,20 +9,20 @@ <% end %> - <%= f.label 'Titel', :class => 'reg-label'%> + <%= f.label 'Titel', class: 'reg-label'%>
    <%= image_tag(@image.foto(:small),class: 'img-responsive')%>
    - <%= f.label 'Beskrivning', :class => 'reg-label'%> + <%= f.label 'Beskrivning', class: 'reg-label'%>
    - <%= f.text_area :description, :class => 'form-control',:placeholder => 'Beskrivning' %> + <%= f.text_area :description, class: 'form-control',:placeholder => 'Beskrivning' %>
    - <%= f.label 'Plats', :class => 'reg-label'%> + <%= f.label 'Plats', class: 'reg-label'%>
    - <%= f.select :subcategory_id, options_from_collection_for_select(@album.subcategories,:id,:text,@image.subcategory_id),{:class => 'form-control',include_blank: true}%> + <%= f.select :subcategory_id, options_from_collection_for_select(@album.subcategories,:id,:text,@image.subcategory_id),{class: 'form-control',include_blank: true}%>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %> - \ No newline at end of file + diff --git a/app/views/images/new.html.erb b/app/views/images/new.html.erb index 3c128607f..4fc1b2c2f 100644 --- a/app/views/images/new.html.erb +++ b/app/views/images/new.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Lägg till bilder i '+@album.title,nil, :class => 'reg-header'%> + <%= label_tag 'Lägg till bilder i '+@album.title,nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa album', @album %>
    <%= link_to 'Tillbaka', :root %>
    -
    \ No newline at end of file + diff --git a/app/views/images/show.html.erb b/app/views/images/show.html.erb index d2130166a..3b41d1a2e 100644 --- a/app/views/images/show.html.erb +++ b/app/views/images/show.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Visa bild',nil, :class => 'reg-header'%> + <%= label_tag 'Visa bild',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa album', @album %>
    <%= link_to 'Tillbaka', :back %>
    -
    \ No newline at end of file + diff --git a/app/views/layouts/_admin_dropdown.html.erb b/app/views/layouts/_admin_dropdown.html.erb new file mode 100644 index 000000000..b32665b52 --- /dev/null +++ b/app/views/layouts/_admin_dropdown.html.erb @@ -0,0 +1,66 @@ + diff --git a/app/views/layouts/_topbar.html.erb b/app/views/layouts/_topbar.html.erb index 60e8f017c..7372ba671 100644 --- a/app/views/layouts/_topbar.html.erb +++ b/app/views/layouts/_topbar.html.erb @@ -1,80 +1,33 @@ +
  • <%= link_to Profile.model_name.human, current_user.profile %>
  • +
  • <%= link_to t('user.settings'), :edit_user_registration %>
  • +
  • <%= link_to t('devise.sign_out'), :destroy_user_session, method: :delete %>
  • + + + <% else %> +
  • + <%= link_to(fa_icon("sign-in") + ' '+ t('devise.sign_in'), new_user_session_path) %> +
  • +
  • +
  • + <%= link_to(fa_icon("plus") + ' ' + t('devise.sign_up'), new_user_registration_path) %> +
  • + <% end %> + diff --git a/app/views/layouts/_utskottmenu.html.erb b/app/views/layouts/_utskottmenu.html.erb deleted file mode 100644 index a182baaf5..000000000 --- a/app/views/layouts/_utskottmenu.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 63039c4fc..9dc7e0007 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -75,7 +75,7 @@ <% if yield(:title) == 'Utskott' %>
    - <%= render "layouts/utskottmenu" %> + <%= render "councils/menu" %>
    <% end %> diff --git a/app/views/menus/_form.html.erb b/app/views/menus/_form.html.erb index 2d8ff6699..f075d9b74 100644 --- a/app/views/menus/_form.html.erb +++ b/app/views/menus/_form.html.erb @@ -1,46 +1,37 @@ -<%= form_for(@menu, :html => { :autocomplete => 'off' }) do |f| %> - <% if @menu.errors.any? %> -
    -

    <%= pluralize(@menu.errors.count, "error") %> gör att menyn inte kan sparas:

    - -
    - <% end %> - <%= f.label 'Meny', :class => 'reg-label'%> -
    - <%= f.select :location, - options_for_select(["Sektionen","För medlemmar","För företag","Kontakt"],@menu.location), - include_blank: true, - :class => "form-control listBox"%> -
    - <%= f.label 'Sorteringsindex', :class => 'reg-label'%> -
    - <%= f.number_field :index,:class => 'form-control' %> -
    - <%= f.label 'Text', :class => 'reg-label'%> -
    - <%= f.text_field :name, :class => 'form-control',:placeholder => 'Text',:autocomplete => 'off' %> -
    - <%= f.label 'Länk', :class => 'reg-label'%> -
    - <%= f.text_field :link, :class => 'form-control',:placeholder => 'Länk',:autocomplete => 'off' %> -
    - <%= f.label 'Synlig', :class => 'reg-label'%> -
    - <%= f.check_box :visible, checked: @menu.visible %> -
    - <%= f.label 'Turbolinks', :class => 'reg-label'%> -
    - <%= f.check_box :turbolinks, checked: @menu.turbolinks %> -
    - <%= f.label 'Öppna i ny tab', :class => 'reg-label'%> -
    - <%= f.check_box :blank_p, checked: @menu.blank_p %> -
    -
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> -
    +<%= form_for(@menu) do |f| %> + <%= render 'shared/form_errors', current: @menu %> + <%= f.label 'Meny', class: 'reg-label' %> +
    + <%= f.select :location, + options_for_select(["Sektionen", "För medlemmar", "För företag", "Kontakt"], @menu.location), + include_blank: true, + class: "form-control listBox" %> +
    + <%= f.label 'Sorteringsindex', class: 'reg-label' %> +
    + <%= f.number_field :index, class: 'form-control' %> +
    + <%= f.label 'Text', class: 'reg-label' %> +
    + <%= f.text_field :name, class: 'form-control', placeholder: 'Text', autocomplete: 'off' %> +
    + <%= f.label 'Länk', class: 'reg-label' %> +
    + <%= f.text_field :link, class: 'form-control', placeholder: 'Länk', autocomplete: 'off' %> +
    + <%= f.label 'Synlig', class: 'reg-label' %> +
    + <%= f.check_box :visible, checked: @menu.visible %> +
    + <%= f.label 'Turbolinks', class: 'reg-label' %> +
    + <%= f.check_box :turbolinks, checked: @menu.turbolinks %> +
    + <%= f.label 'Öppna i ny tab', class: 'reg-label' %> +
    + <%= f.check_box :blank_p, checked: @menu.blank_p %> +
    +
    + <%= f.submit "Spara", class: 'btn-u pull-right' %> +
    <% end %> diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index 2909981c2..afe9b18ad 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -1,21 +1,21 @@ <%= form_for(@news, :html => { :autocomplete => 'off' }) do |f| %> <%= render 'shared/form_errors',current: @news%> - <%= f.label 'Titel', :class => 'reg-label'%> + <%= f.label 'Titel', class: 'reg-label'%>
    - <%= f.text_field :title, :class => 'form-control',:placeholder => 'Titel'%> + <%= f.text_field :title, class: 'form-control',:placeholder => 'Titel'%>
    - <%= f.label 'Innehåll', :class => 'reg-label'%> + <%= f.label 'Innehåll', class: 'reg-label'%>
    - <%= f.text_area :content, :class => 'form-control',:placeholder => 'Innehåll', size: "120x15" %> + <%= f.text_area :content, class: 'form-control',:placeholder => 'Innehåll', size: "120x15" %>
    - <%= f.label 'Visningsbild', :class => 'reg-label'%> + <%= f.label 'Visningsbild', class: 'reg-label'%>
    <% if @news.image != nil%> <%= image_tag(@news.image(:thumb))%> <% end %> - <%= f.file_field :image, :class => 'form-control' %> + <%= f.file_field :image, class: 'form-control' %>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <% end %> diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb index 1b2aa7e68..3de55a0cf 100644 --- a/app/views/news/edit.html.erb +++ b/app/views/news/edit.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Redigera nyhet',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera nyhet',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa nyhet', @news %>
    <%= link_to 'Tillbaka till nyheter', news_index_path %>
    -
    \ No newline at end of file + diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index deffba945..6fd167a3b 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny nyhet',nil, :class => 'reg-header'%> + <%= label_tag 'Ny nyhet',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till nyheter', news_index_path %>
    -
    \ No newline at end of file + diff --git a/app/views/notices/_form.html.erb b/app/views/notices/_form.html.erb index 5919d3773..c3a98203e 100644 --- a/app/views/notices/_form.html.erb +++ b/app/views/notices/_form.html.erb @@ -1,43 +1,43 @@ <%= form_for(@notice) do |f| %> - <%=render 'shared/form_errors', current: @notice%> + <%= render 'shared/form_errors', current: @notice %> - <%= f.label :title, class: 'reg-label'%> + <%= f.label :title, class: 'reg-label' %>
    - <%= f.text_field :title,class: 'form-control' %> + <%= f.text_field :title, class: 'form-control' %>
    - <%= f.label :description, class: 'reg-label'%> + <%= f.label :description, class: 'reg-label' %>
    - <%= f.text_area :description,class: 'form-control',size:"120x10" %> + <%= f.text_area :description, class: 'form-control', size: "120x10" %>
    - <%= f.label :public, class: 'reg-label'%> + <%= f.label :public, class: 'reg-label' %>
    <%= f.check_box :public %>
    - <%= f.label :d_publish, class: 'reg-label'%> + <%= f.label :d_publish, class: 'reg-label' %>
    <%= f.date_field :d_publish, class: "form-control", id: 'datepicker1' %>
    - <%= f.label :d_remove, class: 'reg-label'%> + <%= f.label :d_remove, class: 'reg-label' %>
    <%= f.date_field :d_remove, class: "form-control", id: 'datepicker2' %>
    - <%= f.label :sort, class: 'reg-label'%> + <%= f.label :sort, class: 'reg-label' %>
    - <%= f.number_field :sort ,class: 'form-control'%> + <%= f.number_field :sort, class: 'form-control' %>
    - <%= f.label :image, :class => 'reg-label'%> + <%= f.label :image, class: 'reg-label' %>
    - <% if @notice.image?%> - <%= image_tag(image_notice_path(@notice, style: 'small'))%>
    + <% if @notice.image? %> + <%= image_tag(image_notice_path(@notice, style: 'small')) %>
    <% end %> - <%= f.file_field :image, :class => 'form-control' %> + <%= f.file_field :image, class: 'form-control' %>
    - <%= f.submit class:"btn btn-u" %> + <%= f.submit id: 'submit-notice', class: "btn btn-u" %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/notices/_notice.html.erb b/app/views/notices/_notice.html.erb index 3948e8a90..dc47167f8 100644 --- a/app/views/notices/_notice.html.erb +++ b/app/views/notices/_notice.html.erb @@ -1,13 +1,15 @@ -

    <%=notice.title%>

    +

    <%= notice.title %>

    - <% if notice.image?%> -
    - <%= image_tag image_notice_path(notice,style: "large"), class: "img-responsive"%> -
    -
    - <%else%> -
    - <%end%> - <%=simple_format(notice.description)%> -
    -
    \ No newline at end of file + <% if notice.image? %> +
    + <%= image_tag image_notice_path(notice, style: "large"), class: "img-responsive" %> +
    +
    + <%= simple_format(notice.description) %> +
    + <% else %> +
    + <%= simple_format(notice.description) %> +
    + <% end %> +
    diff --git a/app/views/notices/edit.html.erb b/app/views/notices/edit.html.erb index 26e6f799b..f8d15dc21 100644 --- a/app/views/notices/edit.html.erb +++ b/app/views/notices/edit.html.erb @@ -2,7 +2,7 @@
    - <%= label_tag 'Redigera notis',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera notis',nil, class: 'reg-header'%> <%= render 'form'%>
    <%= link_to('Visa alla notiser',notices_path, class: "btn btn-u")%> diff --git a/app/views/notices/index.html.erb b/app/views/notices/index.html.erb index 6fecb96c7..3448a0382 100644 --- a/app/views/notices/index.html.erb +++ b/app/views/notices/index.html.erb @@ -1,7 +1,7 @@ <% provide(:title, 'Notiser') %>
    -

    Kandidaturer

    +

    Notiser

    <%= grid(@notice_grid) do |g| g.row_attributes do |post| if (post.public == true) @@ -17,4 +17,5 @@ g.column name: "Sorteringsindex", attribute: 'sort' end -%>
    -
    \ No newline at end of file + <%=link_to('Skapa ny', new_notice_path, class: 'btn btn-u')%> +
    diff --git a/app/views/notices/new.html.erb b/app/views/notices/new.html.erb index 298240d17..deda52051 100644 --- a/app/views/notices/new.html.erb +++ b/app/views/notices/new.html.erb @@ -2,11 +2,11 @@
    - <%= label_tag 'Ny notis',nil, :class => 'reg-header'%> + <%= label_tag 'Ny notis',nil, class: 'reg-header'%> <%= render 'form'%>
    <%= link_to('Visa alla notiser',notices_path, class: "btn btn-u")%> <%= link_to('Tillbaka till startsida', root_url, class: "btn btn-u")%>
    -
    \ No newline at end of file +
    diff --git a/app/views/page_elements/_form.html.erb b/app/views/page_elements/_form.html.erb index 8b89d1206..e4ed1603f 100644 --- a/app/views/page_elements/_form.html.erb +++ b/app/views/page_elements/_form.html.erb @@ -1,52 +1,43 @@ -<%= form_for(@page_element,url: @path) do |f| %> - <% if @page_element.errors.any? %> -
    -

    <%= pluralize(@page_element.errors.count, "error") %> gör att sidan inte kan sparas:

    - -
    - <% end %> - <%= f.label 'Namn', :class => 'reg-label'%> +<%= form_for([@page,@page_element]) do |f| %> + <%= render 'shared/form_errors', current: @page_element%> + <%= f.label 'Namn', class: 'reg-label'%>
    För att ni ska kunna skilja på olika element. - <%= f.text_field :name,:class => 'form-control' %> + <%= f.text_field :name,class: 'form-control' %>
    - <%= f.label 'Synlig?', :class => 'reg-label'%> - <%= f.check_box :visible,:class => 'form-control' %> + <%= f.label 'Synlig?', class: 'reg-label'%> + <%= f.check_box :visible,class: 'form-control' %> - <%= f.label 'Text', :class => 'reg-label'%> + <%= f.label 'Text', class: 'reg-label'%>
    - <%= f.text_area :text,:class => 'form-control', size: "60x8" %> + <%= f.text_area :text,class: 'form-control', size: "60x8" %>
    - <%= f.label 'Rubrik', :class => 'reg-label'%> + <%= f.label 'Rubrik', class: 'reg-label'%>
    Lämnas tomt för element utan rubrik - <%= f.text_field :headline,:class => 'form-control' %> + <%= f.text_field :headline,class: 'form-control' %>
    <%if 1 == 0%> - <%= f.label 'Ram?', :class => 'reg-label'%> - <%= f.check_box :border,:class => 'form-control' %> + <%= f.label 'Ram?', class: 'reg-label'%> + <%= f.check_box :border,class: 'form-control' %> <%end%> - <%= f.label 'Position?', :class => 'reg-label'%>
    + <%= f.label 'Position?', class: 'reg-label'%>
    <%= f.radio_button :sidebar, false,checked: true %> - <%= f.label :sidebar, 'Huvudfält', :value => false,:class => 'reg-label' %> + <%= f.label :sidebar, 'Huvudfält', :value => false,class: 'reg-label' %> <%= f.radio_button :sidebar, true %> - <%= f.label :sidebar, 'Sidofält', :value => true,:class => 'reg-label' %>
    + <%= f.label :sidebar, 'Sidofält', :value => true,class: 'reg-label' %>
    - <%= f.label 'Sorteringsindex', :class => 'reg-label'%> + <%= f.label 'Sorteringsindex', class: 'reg-label'%>
    Elementen i sidofältet och huvudfältet sorteras efter detta nummer. - <%= f.number_field :displayIndex,:class => 'form-control' %> + <%= f.number_field :displayIndex,class: 'form-control' %>
    - <%= f.label 'Bild', :class => 'reg-label'%> + <%= f.label 'Bild', class: 'reg-label'%>
    - <%= f.file_field :picture,:class => 'form-control' %> + <%= f.file_field :picture,class: 'form-control' %>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    <%end%> diff --git a/app/views/page_elements/_page_element.html.erb b/app/views/page_elements/_page_element.html.erb new file mode 100644 index 000000000..63601dc7a --- /dev/null +++ b/app/views/page_elements/_page_element.html.erb @@ -0,0 +1,26 @@ +<% if @edit %> +
    +<% end %> +<% if page_element.headline.present? %> +

    <%= page_element.headline %>

    +<% end %> +<% if page_element.text.present? %> + <%= simple_format(page_element.text) %> +<% end %> + +<% if @edit %> +
    + +<% end %> +<% if @edit %> +
    +<% end %> + diff --git a/app/views/page_elements/edit.html.erb b/app/views/page_elements/edit.html.erb index 92b8857d9..93b4a234b 100644 --- a/app/views/page_elements/edit.html.erb +++ b/app/views/page_elements/edit.html.erb @@ -1,11 +1,13 @@
    -
    -
    - <%= label_tag 'Redigera element',nil, :class => 'reg-header'%> - <%= render 'form'%> - <%= link_to 'Visa sida', council_page_path(@council)%>
    - <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), council_page_page_element_path(@council,@page_element), method: :delete, data: {confirm: "Är du säker?"}, class: "btn-u btn-u-small" %> - <%= link_to 'Tillbaka till startsida', root_url %> -
    -
    -
    \ No newline at end of file +
    +
    + <%= label_tag 'Redigera element', nil, class: 'reg-header' %> + <%= render 'form' %> + <%= link_to 'Visa sida', @page %>
    + <%= link_to (content_tag(:i, nil, class: "fa fa-trash-o") + " Förinta"), + page_page_element_path(@page, @page_element), method: :delete, + data: {confirm: "Är du säker?"}, class: "btn-u btn-u-small" %> + <%= link_to 'Tillbaka till startsida', root_url %> +
    +
    +
    diff --git a/app/views/page_elements/index.html.erb b/app/views/page_elements/index.html.erb index a9361dbec..c89dca045 100644 --- a/app/views/page_elements/index.html.erb +++ b/app/views/page_elements/index.html.erb @@ -1,26 +1,30 @@ -<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa sida"), council_page_path(@council), class: "btn-u btn-u-small"%> -<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa alla element"), council_page_page_elements_path(@council), class: "btn-u btn-u-small"%> +<%= link_to(fa_icon('edit') +' Redigera sida' , + page_path(@page), class: "btn-u btn-u-small")%> +<%= link_to(fa_icon('edit') + ' Lägg till nytt element', + new_page_page_element_path(@page,@page_element), + class: "btn-u btn-u-small")%>
    -
    -

    Sida

    -
    -
    -
      - <% @page_elements.each do |p| %> -
    • -
      -
      -

      <%=p.name%>

      -
      -
      -
      <%=simple_format(p.text)%> - <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Redigera"), edit_council_page_page_element_path(@council,p), class: "btn-u btn-u-small"%> -
      -
      -
    • - <% end %> -
    -
    -
    -
    -
    \ No newline at end of file +
    +

    Sida

    +
    +
    +
      + <% @page_elements.each do |p| %> +
    • +
      +
      +

      <%= p.name %>

      +
      +
      +
      <%= simple_format(p.text) %> + <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Redigera"), + edit_page_page_element_path(@page, p), class: "btn-u btn-u-small" %> +
      +
      +
    • + <% end %> +
    +
    +
    +
    +
    diff --git a/app/views/page_elements/index.json.jbuilder b/app/views/page_elements/index.json.jbuilder deleted file mode 100644 index ed1cbcf14..000000000 --- a/app/views/page_elements/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@pages) do |page| - json.extract! page, :id - json.url page_url(page, format: :json) -end diff --git a/app/views/page_elements/new.html.erb b/app/views/page_elements/new.html.erb index 476f62154..736464f6d 100644 --- a/app/views/page_elements/new.html.erb +++ b/app/views/page_elements/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Nytt element',nil, :class => 'reg-header'%> + <%= label_tag 'Nytt element',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/page_elements/show.html.erb b/app/views/page_elements/show.html.erb index 0350aa16a..e1f51266d 100644 --- a/app/views/page_elements/show.html.erb +++ b/app/views/page_elements/show.html.erb @@ -1,7 +1,7 @@
    -

    <%= "Titel" +@page_element.to_s %>

    +

    <%= %("Titel" +@page_element.name) %>

    -
    \ No newline at end of file + diff --git a/app/views/page_elements/show.json.jbuilder b/app/views/page_elements/show.json.jbuilder deleted file mode 100644 index 1949648a2..000000000 --- a/app/views/page_elements/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @page, :id, :created_at, :updated_at diff --git a/app/views/pages/_form.html.erb b/app/views/pages/_form.html.erb index 2d761b41d..7ddbfc956 100644 --- a/app/views/pages/_form.html.erb +++ b/app/views/pages/_form.html.erb @@ -1,16 +1,24 @@ -<%= form_for(@page, :html => { :autocomplete => 'off' }) do |f| %> - <% if @page.errors.any? %> -
    -

    <%= pluralize(@page.errors.count, "error") %> gör att sidan inte kan sparas:

    - - -
    - <% end %> -
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> -
    +<%= form_for(@page) do |f| %> + <%= render 'shared/form_errors', current: @page %> + <%= f.label :title, class: 'reg-label' %> +
    + <%= f.text_field :title, class: 'form-control', placeholder: 'Titel' %> +
    + <% if @page.council.present? %> + <%= f.label 'Sida', class: 'reg-label' %> +
    + <%= link_to(@page.council, @page.council) %> +
    + <% end %> + <%= f.label :url, class: 'reg-label' %> +
    + <%= f.text_field :url, class: 'form-control', placeholder: 'Url' %> +
    + <%= f.label :visible, class: 'reg-label' %> +
    + <%= f.check_box :visible, checked: @page.visible %> +
    +
    + <%= f.submit "Spara", class: 'btn-u pull-right' %> +
    <% end %> diff --git a/app/views/pages/_main.html.erb b/app/views/pages/_main.html.erb deleted file mode 100644 index 157592be9..000000000 --- a/app/views/pages/_main.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -

    <%= @council.title %>

    -
    -
    -
    - - <%if @mainelements%> - <%@mainelements.each do |p|%> -
    - <%@main = p%> - <%=render partial: "pages/element"%> -
    -
    - <%end%> - <%end%> -
    - <%= render partial: "pages/sidebar"%> - -
    -
    - - <%if (@poster) && (@poster.count > 0)%> -
    -

    Poster

    - -
    - <%@first = true%> - <% @poster.each do |post|%> - <%if @first%> -
    - <%else%> -
    - <%end%> -
    -
    - <%=simple_format(post.description)%> -
    -
    -
    - <%@first = false%> - <%end%> -
    -
    - - <%end%> -
    diff --git a/app/views/pages/_page.html.erb b/app/views/pages/_page.html.erb new file mode 100644 index 000000000..884521fe0 --- /dev/null +++ b/app/views/pages/_page.html.erb @@ -0,0 +1,9 @@ +

    <%= page.title %>

    +
    + + <%= render page.main %> +
    + +
    + <%= render page.side %> +
    diff --git a/app/views/pages/_sidebar.html.erb b/app/views/pages/_sidebar.html.erb deleted file mode 100644 index 4326f2cde..000000000 --- a/app/views/pages/_sidebar.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -
    - -
    - <%= render 'pages/president'%> -
    - - <%if @sidebarelements%> - <%@sidebarelements.each do |p|%> -
    - <%@main = p%> - <%=render partial: "pages/element"%> -
    -
    - <%end%> - <%end%> - <%if 1 == 0%> - -
    -

    Recent Blog Entries

    -
    -
    -
    -

    Lorem sequat ipsum dolor lorem sunt aliqua put

    -
    -
    -
    -
    -
    -

    It works on all major web browsers tablets

    -
    -
    -
    -
    -
    -

    Brunch 3 wolf moon tempor sunt aliqua put.

    -
    -
    -
    - <%end%> -
    \ No newline at end of file diff --git a/app/views/pages/edit.html.erb b/app/views/pages/edit.html.erb index 982480656..334f4f2ab 100644 --- a/app/views/pages/edit.html.erb +++ b/app/views/pages/edit.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Redigera sida',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera sida',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa sida', @page %>
    <%= link_to 'Tillbaka till startsida', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index 648ca814d..b29039d7c 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -1,17 +1,35 @@ -%h1 Listing pages - -%table - %tr - %th - %th - %th - - - @pages.each do |page| - %tr - %td= link_to 'Show', page - %td= link_to 'Edit', edit_page_path(page) - %td= link_to 'Destroy', page, :method => :delete, :data => { :confirm => 'Are you sure?' } - -%br - -= link_to 'New Page', new_page_path +
    +
    +
    +
    +

    + Sidor

    + <%= link_to('Skapa ny', new_page_path, class: 'btn btn-u') %> +
    + + + + + + + + + + + + + <% @pages.each do |page| %> + + + + + + + + + <% end %> + +
    IdUrlSynligUtskottUppdateradRedigera
    <%= page.id %><%= page.url %><%= page.visible %><%= (page.council.nil?) ? link_to(page.council, page.council) : 'Inget' %><%= page.updated_at %><%= link_to('Redigera', edit_page_path(page), class: "btn btn-u") %>
    +
    +
    +
    diff --git a/app/views/pages/index.json.jbuilder b/app/views/pages/index.json.jbuilder deleted file mode 100644 index ed1cbcf14..000000000 --- a/app/views/pages/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@pages) do |page| - json.extract! page, :id - json.url page_url(page, format: :json) -end diff --git a/app/views/pages/new.html.erb b/app/views/pages/new.html.erb index 32cc97609..c575b48b1 100644 --- a/app/views/pages/new.html.erb +++ b/app/views/pages/new.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Ny sida',nil, :class => 'reg-header'%> + <%= label_tag 'Ny sida',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till start', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/pages/show.html.erb b/app/views/pages/show.html.erb index c0ff47f65..4fc010edc 100644 --- a/app/views/pages/show.html.erb +++ b/app/views/pages/show.html.erb @@ -1,8 +1,8 @@ -<% @edit = true%> -<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Lägg till element"), new_council_page_page_element_path(@council), class: "btn-u btn-u-small"%> -<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa alla element"), council_page_page_elements_path(@council), class: "btn-u btn-u-small"%>
    +<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Lägg till element"), + new_page_page_element_path(@page), class: "btn-u btn-u-small" %> +<%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa alla element"), + page_page_elements_path(@page), class: "btn-u btn-u-small" %> +
    Den här sidan visas endast för de med rättighet att redigera. För att se hur sidan faktiskt se ut gå till: -

    <%= link_to (content_tag(:i, nil, class: "fa fa-edit") + " Visa utskottssida"), council_path(@council), class: "btn-u btn-u-small"%>
    -
    -<%=render partial: "main"%> \ No newline at end of file +<%= render @page %> diff --git a/app/views/pages/show.json.jbuilder b/app/views/pages/show.json.jbuilder deleted file mode 100644 index 1949648a2..000000000 --- a/app/views/pages/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @page, :id, :created_at, :updated_at diff --git a/app/views/posts/_table.html.erb b/app/views/posts/_table.html.erb new file mode 100644 index 000000000..c9607a946 --- /dev/null +++ b/app/views/posts/_table.html.erb @@ -0,0 +1,35 @@ +
    +

    Poster

    + +
    + <% first = true %> + <% collection.each do |post| %> +
    +
    +
    + Beskrivning: <%= simple_format(post.description) %> +
    +
    + Vem har posten just nu? +
      + <% post.profiles.each do |profile|%> +
    • <%=profile.full_name%>
    • + <%end%> +
    + +
    +
    +
    + <% first = false %> + <% end %> +
    +
    + diff --git a/app/views/posts/edit.html.erb b/app/views/posts/edit.html.erb index bc39d0cb8..78f86c3ed 100644 --- a/app/views/posts/edit.html.erb +++ b/app/views/posts/edit.html.erb @@ -1,7 +1,7 @@
    - <%= label_tag 'Redigera post',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera post',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Radera post', council_post_path(@council,@post),method: :delete %>
    <%= link_to 'Visa utskottets poster', council_posts_path(@council) %>
    @@ -9,4 +9,4 @@ <%= link_to 'Tillbaka till startsida', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 8adf8aa1f..522475217 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -1,75 +1,86 @@ <% title('Poster') %>
    - <%if @council%> -
    - <%= link_to "Lägg till post", new_council_post_path(@council) ,class:"btn btn-u"%> - <%= link_to "Visa utskott", council_path(@council),class:"btn btn-u"%> - <%= link_to "Redigera utskott", edit_council_path(@council),class:"btn btn-u"%> -
    - <%end%> -
    - <%= grid(@post_grid) do |g| - g.column name: "Titel",attribute: "title",filter: false do |post| - link_to(post.title,edit_council_post_path(post.council,post)) - link_to(post.title,"#mer-"+post.id.to_s,class: "",data: {toggle: "collapse"}) - end - g.column name: "Gräns",attribute: "limit",filter: false do |post| - (post.limit) && (post.limit > 0) ? post.limit : "Ingen" - end - - g.column name: "Utskott", attribute: "council_id",filter: false do |post| - link_to(post.council.title,council_path(post.council)) - end - g.column name: "Styrelsepost?", attribute: "styrelse" , filter: false do |post| - (post.styrelse) ? "Ja" : "Nej" - end - - g.column name: "Väljs av:", attribute: "elected_by",filter: false - - g.column name: "HT/VT?",attribute: "elected_at",filter: false - if can? :edit, @post - g.column do |post| - link_to('Redigera', edit_council_post_path(post.council,post)) - end - end - end -%> -
    -
    - <%for @post in @posts%> -
    -
    -

    <%=@post.title%>

    -
    - <% if can? :edit, @post %> + <% if @council %> +
    + <%= link_to "Lägg till post", new_council_post_path(@council), class: "btn btn-u" %> + <%= link_to "Visa utskott", council_path(@council), class: "btn btn-u" %> + <%= link_to "Redigera utskott", edit_council_path(@council), class: "btn btn-u" %> +
    + <% end %> +
    +
    +

    Sök på ett namn, räcker med en bokstav.

    + <%= form_tag(search_profiles_path, method: :patch, remote: true) do %> + <%= text_field_tag :name, nil, placeholder: :name %> + <%= text_field_tag :lastname, nil, placeholder: :lastname %> + <%= submit_tag 'Sök', class: 'btn-u btn-u-small' %> + <% end %> +
    +
    + <%= form_tag(add_profile_posts_path, method: :patch) do %> + <%= select_tag :profile_id, @search_profiles %> + <%= select_tag :post_id, options_from_collection_for_select(@posts, 'id', 'title') %> + <%= submit_tag 'Spara', class: 'btn-u-small btn-u' %> + <% end %> +
    +
    +
    + <%= grid(@post_grid) do |g| + g.column name: "Titel", attribute: "title", filter: false do |post| + link_to(post.title, edit_council_post_path(post.council, post)) + link_to(post.title, "#mer-"+post.id.to_s, class: "", data: {toggle: "collapse"}) + end + g.column name: "Gräns", attribute: "limit", filter: false do |post| + (post.limit) && (post.limit > 0) ? post.limit : "Ingen" + end + + g.column name: "Utskott", attribute: "council_id", filter: false do |post| + link_to(post.council.title, council_path(post.council)) + end + g.column name: "Styrelsepost?", attribute: "styrelse", filter: false do |post| + (post.styrelse) ? "Ja" : "Nej" + end + + g.column name: "Väljs av:", attribute: "elected_by", filter: false + + g.column name: "HT/VT?", attribute: "elected_at", filter: false + if can? :edit, @post + g.column do |post| + link_to('Redigera', edit_council_post_path(post.council, post)) + end + end + end -%> +
    +
    + <% for @post in @posts %> +
    +
    +

    <%= @post.title %>

    + +
    + <% if can? :edit, @post %> <%= link_to 'Ändra posten', edit_council_post_path(@post.council, @post) %> - <% if @post.profiles.size > 0 %> -

    Ta bort någon från posten.

    - <%= form_tag remove_profile_council_post_path(@post.council,@post), :method => :patch do%> - <%= hidden_field_tag :id, @post.id%> - <% profileList = [] %> - <% @post.profiles.each do |profile|%> - <%profileList << [profile.name.to_s + " - " + profile.user.username,profile.id]%> - <% end %> - <%= select_tag :profile_id, options_for_select(profileList)%> - <%= submit_tag 'Ta bort', class: "btn btn-u",data: { confirm: "Den valda profilen kommer att bli av med vald post."} %> - <% end %>
    - <%end%> -

    Lägg till någon på posten: (Skriv in användarnamn)

    - <%= form_tag add_profile_username_council_post_url(@post.council,@post), :method => :patch do%> - <%= hidden_field_tag :id, @post.id%> - <%= text_field_tag :username %> - <%= submit_tag "Spara", class: "btn-u btn",data: { confirm: 'Dubbelkollat användarnamnet?' }%> - <%end%> - - <%end%> -

    Beskrivning:

    - <%if @post.description%> - <%=simple_format(@post.description)%> - <%end%> - -
    -
    -
    - <%end%> -
    + <% if @post.profiles.size > 0 %> +

    Ta bort någon från posten.

    + <%= form_tag remove_profile_council_post_path(@post.council, @post), method: :patch do %> + <%= hidden_field_tag :id, @post.id %> + <% profileList = [] %> + <% @post.profiles.each do |profile| %> + <% profileList << [profile.name.to_s + " - " + profile.user.username, profile.id] %> + <% end %> + <%= select_tag :profile_id, options_for_select(profileList) %> + <%= submit_tag 'Ta bort', class: "btn btn-u", data: {confirm: "Den valda profilen kommer att bli av med vald post."} %> + <% end %>
    + <% end %> + <% end %> +

    Beskrivning:

    + <% if @post.description %> + <%= simple_format(@post.description) %> + <% end %> + +
    +
    +
    + <% end %> +
    diff --git a/app/views/posts/new.html.erb b/app/views/posts/new.html.erb index f840ecd4d..57f728de8 100644 --- a/app/views/posts/new.html.erb +++ b/app/views/posts/new.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Ny post',nil, :class => 'reg-header'%> + <%= label_tag 'Ny post',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa utskott', @council %>
    <%= link_to 'Tillbaka till startsida', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/profiles/_form.html.erb b/app/views/profiles/_form.html.erb index f993e135f..fc3f76e52 100644 --- a/app/views/profiles/_form.html.erb +++ b/app/views/profiles/_form.html.erb @@ -1,51 +1,51 @@ <%= form_for(@profile) do |f| %> <%= render 'shared/form_errors', current: @profile%> - <%= f.label 'Namn och efternamn', :class => 'reg-label'%> + <%= f.label 'Namn och efternamn', class: 'reg-label'%>
    - <%= f.text_field :name, :class => 'form-control',:placeholder => 'Namn'%> - <%= f.text_field :lastname, :class => 'form-control',:placeholder => 'Efternamn'%> + <%= f.text_field :name, class: 'form-control',:placeholder => 'Namn'%> + <%= f.text_field :lastname, class: 'form-control',:placeholder => 'Efternamn'%>
    - <%= f.label 'Program', :class => 'reg-label'%> + <%= f.label 'Program', class: 'reg-label'%>
    <%= f.select :program, options_for_select([ [" ","Oklart"], ["Teknisk Fysik"], ["Teknisk Matematik"], - ["Teknisk Nanovetenskap"]],@profile.program),{}, html_options = {:class => "listBox form-control",:selected => :program , :style=>"float:left;"} %> + ["Teknisk Nanovetenskap"]],@profile.program),{}, html_options = {class: "listBox form-control",:selected => :program , :style=>"float:left;"} %>
    - <%= f.label 'Började på programmet', :class => 'reg-label'%> + <%= f.label 'Började på programmet', class: 'reg-label'%>
    <%= f.select( :start_year, (1954..(Time.zone.now.year+1)).to_a.reverse!, class: "form-control")%>
    - <%= f.label 'Profilbild', :class => 'reg-label'%> + <%= f.label 'Profilbild', class: 'reg-label'%>
    <% if @profile.avatar_file_name%> <%= image_tag(@profile.avatar(:thumb))%> <% end %> - <%= f.file_field :avatar, :class => 'form-control' %> + <%= f.file_field :avatar, class: 'form-control' %>
    <% if @profile.posts.count > 0%> - <%= f.label 'Visningspost', :class => 'reg-label'%> + <%= f.label 'Visningspost', class: 'reg-label'%>
    - <%= f.select :first_post, options_for_select(@profile.posts.collect{ |r| [r.title, r.id] }),:class => 'form-control'%> + <%= f.select :first_post, options_for_select(@profile.posts.collect{ |r| [r.title, r.id] }),class: 'form-control'%>
    <% end %>
    Nedanstående fält är till för t.ex. sektionsval,
    uppgifterna i fälten kan endast ses av dig själv,styrelsen och valberedningen.
    - <%= f.label 'STIL-id', :class => 'reg-label'%> + <%= f.label 'STIL-id', class: 'reg-label'%>
    <%= f.text_field :stil_id, placeholder: "Stil-id", class: "form-control"%>
    - <%= f.label 'E-post', :class => 'reg-label'%> + <%= f.label 'E-post', class: 'reg-label'%>
    <%= f.text_field :email, placeholder: "E-post", class: "form-control"%>
    - <%= f.label 'Telefonnummer', :class => 'reg-label'%> + <%= f.label 'Telefonnummer', class: 'reg-label'%>
    <%= f.text_field :phone, placeholder: "Telefonnumer", class: "form-control"%>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb index 8b43ee94a..d47b4e248 100644 --- a/app/views/profiles/edit.html.erb +++ b/app/views/profiles/edit.html.erb @@ -1,9 +1,9 @@
    - <%= label_tag 'Redigera din användarprofil',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera din användarprofil',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Tillbaka till profilen', @profile %>
    -
    \ No newline at end of file + diff --git a/app/views/profiles/search.js.erb b/app/views/profiles/search.js.erb new file mode 100644 index 000000000..32732f3b4 --- /dev/null +++ b/app/views/profiles/search.js.erb @@ -0,0 +1,4 @@ +// This might be the wrong way to do this. +<% if @search_profiles %> +$('#profile_id').html("<%=j options_from_collection_for_select(@search_profiles, :id, :full_print) %>"); +<% end %> diff --git a/app/views/proposals/form.html.haml b/app/views/proposals/form.html.haml index 529078648..e0f3e819a 100644 --- a/app/views/proposals/form.html.haml +++ b/app/views/proposals/form.html.haml @@ -13,7 +13,7 @@ skulle råka ladda om sidan. = form_for @proposal, :url => proposals_generate_path(:format => :pdf), - :html => { :class => 'proposal-form' }do |f| + :html => { class: 'proposal-form' }do |f| %fieldset %legend Grundläggande information @@ -50,5 +50,5 @@ Yrka mindre! %hr - = f.submit 'Skapa motion!', :class => 'btn btn-default' + = f.submit 'Skapa motion!', class: 'btn btn-default' diff --git a/app/views/short_links/_form.html.haml b/app/views/short_links/_form.html.haml index 9c02caa0b..48c8e7af1 100644 --- a/app/views/short_links/_form.html.haml +++ b/app/views/short_links/_form.html.haml @@ -1,19 +1,19 @@ = form_for @short_link, - :html => { :class => 'form-inline shortlink-check' } do |f| + :html => { class: 'form-inline shortlink-check' } do |f| .form-group - = f.label :link, :class => 'sr-only' - = f.text_field :link, :class => 'form-control shortlink-field', + = f.label :link, class: 'sr-only' + = f.text_field :link, class: 'form-control shortlink-field', :placeholder => ShortLink.human_attribute_name(:link) %span ⟶ .form-group - = f.label :target, :class => 'sr-only' - = f.text_field :target, :class => 'form-control', + = f.label :target, class: 'sr-only' + = f.text_field :target, class: 'form-control', :placeholder => ShortLink.human_attribute_name(:target) - = f.submit 'Skapa ny snabblänk', :class => 'btn btn-default' + = f.submit 'Skapa ny snabblänk', class: 'btn btn-default' %p.shortlink-notice{ :style => 'display: none' } En snabblänk med det namnet finns redan. Du kommer att spara över diff --git a/app/views/work_posts/_form.html.erb b/app/views/work_posts/_form.html.erb index fc157d0db..45946c811 100644 --- a/app/views/work_posts/_form.html.erb +++ b/app/views/work_posts/_form.html.erb @@ -11,57 +11,57 @@ <% end %>
    - <%= f.label 'Titel', :class => 'reg-label'%> + <%= f.label 'Titel', class: 'reg-label'%>
    - <%= f.text_field :title,:class => 'form-control' %> + <%= f.text_field :title,class: 'form-control' %>
    - <%= f.label 'Text', :class => 'reg-label'%> + <%= f.label 'Text', class: 'reg-label'%>
    - <%= f.text_area :description,:class => 'form-control', size: "60x8" %> + <%= f.text_area :description,class: 'form-control', size: "60x8" %>
    - <%= f.label 'Företag', :class => 'reg-label'%> + <%= f.label 'Företag', class: 'reg-label'%>
    - <%= f.text_field :company,:class => 'form-control' %> + <%= f.text_field :company,class: 'form-control' %>
    - <%= f.label 'Område', :class => 'reg-label'%> + <%= f.label 'Område', class: 'reg-label'%>
    - <%= f.text_field :category,:class => 'form-control' %> + <%= f.text_field :category,class: 'form-control' %>
    - <%= f.label 'Typ', :class => 'reg-label'%> + <%= f.label 'Typ', class: 'reg-label'%>
    - <%= f.text_field :kind,:class => 'form-control' %> + <%= f.text_field :kind,class: 'form-control' %>
    - <%= f.label 'Målgrupp', :class => 'reg-label'%> + <%= f.label 'Målgrupp', class: 'reg-label'%>
    - <%= f.text_field :for,:class => 'form-control' %> + <%= f.text_field :for,class: 'form-control' %>
    - <%= f.label 'Länk', :class => 'reg-label'%> + <%= f.label 'Länk', class: 'reg-label'%>
    - <%= f.text_field :link,:class => 'form-control' %> + <%= f.text_field :link,class: 'form-control' %>
    - <%= f.label 'Synlig?', :class => 'reg-label'%> - <%= f.check_box :visible,:class => 'form-control' %> - <%= f.label 'Deadline', :class => 'reg-label'%>
    + <%= f.label 'Synlig?', class: 'reg-label'%> + <%= f.check_box :visible,class: 'form-control' %> + <%= f.label 'Deadline', class: 'reg-label'%>
    Fulfix: för ingen deadline, sätt ett datum efter
    2100-03-25
    - <%= f.date_field :deadline, :class => 'form-control' %> + <%= f.date_field :deadline, class: 'form-control' %>
    - <%= f.label 'Publicera', :class => 'reg-label'%>
    + <%= f.label 'Publicera', class: 'reg-label'%>
    Måste sättas, sätt idag för att visa direkt.
    - <%= f.date_field :publish, :class => 'form-control' %> + <%= f.date_field :publish, class: 'form-control' %>
    - <%= f.label 'Bild', :class => 'reg-label'%> + <%= f.label 'Bild', class: 'reg-label'%> <% if @work_post.picture_file_name%> <%= image_tag(@work_post.picture(:view),class: "img-responsive")%>
    <% end %>
    - <%= f.file_field :picture,:class => 'form-control' %> + <%= f.file_field :picture,class: 'form-control' %>
    - <%= f.submit "Spara",:class => 'btn-u pull-right' %> + <%= f.submit "Spara",class: 'btn-u pull-right' %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/work_posts/edit.html.erb b/app/views/work_posts/edit.html.erb index bdab12c6e..c8c70cf65 100644 --- a/app/views/work_posts/edit.html.erb +++ b/app/views/work_posts/edit.html.erb @@ -1,11 +1,11 @@
    - <%= label_tag 'Redigera jobbpost',nil, :class => 'reg-header'%> + <%= label_tag 'Redigera jobbpost',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Radera post', work_post_path(@work_post),method: :delete %>
    <%= link_to 'Visa poster', work_posts_path %>
    <%= link_to 'Tillbaka till startsida', root_url %>
    -
    \ No newline at end of file + diff --git a/app/views/work_posts/new.html.erb b/app/views/work_posts/new.html.erb index 9452170fe..9f77e2ecb 100644 --- a/app/views/work_posts/new.html.erb +++ b/app/views/work_posts/new.html.erb @@ -1,10 +1,10 @@
    - <%= label_tag 'Ny jobbpost',nil, :class => 'reg-header'%> + <%= label_tag 'Ny jobbpost',nil, class: 'reg-header'%> <%= render 'form'%> <%= link_to 'Visa jobbposter',work_posts_path %>
    <%= link_to 'Tillbaka till startsida', root_url %>
    -
    \ No newline at end of file + diff --git a/config/locales/active_record.sv.yml b/config/locales/active_record.sv.yml new file mode 100644 index 000000000..7a4f4a062 --- /dev/null +++ b/config/locales/active_record.sv.yml @@ -0,0 +1,81 @@ +sv: + activerecord: + models: + album: Album + cafe_work: Cafejobb + candidate: + one: Kandidatur + other: Kandidaturer + constant: + one: Konstant + other: Konstanter + attributes: + value: Värde + contact: Kontakt + council: Utskott + document: Dokument + election: Val + event: Event + faq: Faq + image: + one: Bild + other: Bilder + menu: + one: Meny + other: Menyer + news: + one: Nyhet + other: Nyheter + nomination: + one: Nominering + other: Nomineringar + notice: + one: Notis + other: Notiser + page: + one: Sida + other: Sidor + page_element: Sidelement + permission: + one: Rättighet + other: Rättigheter + post: + one: Post + other: Poster + profile: + one: Profil + other: Profiler + rent: + one: Bilbokning + other: Bilbokningar + role: + one: Roll + other: Roller + short_link: + one: Snabblänk + other: Snabblänkar + user: Användare + work_post: + one: Jobbpost + other: Jobbposter + attributes: + cafe_work: + work_day: Arbetsdag + d_year: År + pass: Pass + lp: Läsperiod + lv: Läsvecka + short_link: + link: Länknamn + target: Måladress + errors: + messages: + record_invalid: Ogiltlig objekt + + + activemodel: + attributes: + proposal: + title: Rubrik + sign_name: Ditt namn + sign_title: Din titel (valfritt) diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 379b2bc36..d344dcb71 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -2,6 +2,15 @@ en: devise: + remember_me: Remember me? + sign_in: Sign in + sign_out: Sign out + sign_up: Sign up + password_forgotten: Forgotten password? + sign_in_with: Sign in with + not_receive_unlock: Did not receive email about unlocking? + not_receive_confirm: Did not receive confirmation email? + confirmations: confirmed: "Your account was successfully confirmed." send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." diff --git a/config/locales/devise.sv.yml b/config/locales/devise.sv.yml index e2d2afe81..b5ae62b95 100644 --- a/config/locales/devise.sv.yml +++ b/config/locales/devise.sv.yml @@ -10,6 +10,15 @@ sv: other: "%{count} fel hindrade denna %{resource} från att sparas:" devise: + remember_me: Kom ihåg mig? + sign_in: Logga in + sign_out: Logga ut + sign_up: Ny användare + password_forgotten: Glömt lösenord? + sign_in_with: Logga in med + not_receive_unlock: Fick inget upplåsningsmail? + not_receive_confirm: Fick inget bekräftelsemail? + failure: already_authenticated: 'Du har redan loggat in.' unauthenticated: 'Du måste logga in eller skapa ett konto innan du kan fortsätta.' @@ -54,4 +63,5 @@ sv: reset_password_instructions: subject: 'Instruktioner om återställning av lösenord' unlock_instructions: - subject: 'Instruktioner om upplåsning av konto' \ No newline at end of file + subject: 'Instruktioner om upplåsning av konto' + diff --git a/config/locales/en.yml b/config/locales/en.yml index d0262455c..9fc4af524 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,8 +26,49 @@ en: Hello: Hello success_create: was successfully created success_update: was successfully updated - notice: Notice your_profile: Your profile profile_add_information: You have to fill out your name and surname. Please fill out the other information as well. error: error prevent_save: prevents the save + try_login: try to login. + + administrate: Administration + + devise: + + + user: + settings: Account settings + registation: + civic_check: To control memebership in the Guild, will not be saved. + + attributes: + civic: Civic - 10 letters + helpers: + submit: + nomination: + create: Send %{model} + + actions: + back: Back + + elections: + orange_posts: Orange color marks the post is part of the board + green_posts: Green color marks the post as elected by Studierådet + x_posts: Posts marked with (x) have a fixed limit. + star_posts: Posts where limit is marked with * does not have a set limit. + posts_before: Posts which will be able to candidate to + posts_during: Posts which you can candidate to + posts_after: Posts which you can no longer candidate to + get_in_touch: Does anything look strange or do you get stuck? Contact + + nominations: + thank_you: Thanks for your Nomination. + status_after: You can only nominate people to posts not elected at the Vårterminsmöte + + candidates: + similar_candidate: already have a similar candidate + + posts: + already_have_post: already have the post + limited: the post reached its limit. diff --git a/config/locales/sv.the_role.yml b/config/locales/sv.the_role.yml deleted file mode 100644 index 2a0ee0fb8..000000000 --- a/config/locales/sv.the_role.yml +++ /dev/null @@ -1,17 +0,0 @@ -sv: - the_role: - role_created: Roll skapades - role_updated: Roll uppdaterades - role_deleted: Roll togs bort - section_created: Sektion skapades - section_not_created: Sektion skapades inte - section_rule_created: "Sektionsregel skapad" - section_rule_not_created: "Sektionsregel ej skapad" - section_rule_on: "Sektionsregel aktiverad" - section_rule_off: "Sektionsregel inaktiverad" - state_not_changed: "Sektionsregel ej ändraded" - section_deleted: Sektion borttagen - section_not_deleted: Sektion ej borttagen - section_rule_deleted: "Sektionsregel borttagen" - section_rule_not_deleted: "Sektionsregel ej borttagen" - access_denied: "Åtkomst nekad" \ No newline at end of file diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 28546afbd..bda20e448 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1,11 +1,13 @@ sv: success_create: har skapats success_update: har uppdaterats - notice: Notisen profile_add_information: Du behöver fylla i namn och efternamn. Fyll gärna i den andra informationen också. your_profile: Din profil error: fel prevent_save: gör att det inte går att spara + try_login: prova att logga in. + + administrate: Administrera attributes: description: Beskrivning @@ -29,86 +31,10 @@ sv: council: Utskott comment: Kommentar access_code: Kod - - models: - notice: Notis - candidate: - one: Kandidatur - other: Kandidaturer - profile: - one: Profil - other: Profiler - - activerecord: - models: - candidate: - one: Kandidatur - other: Kandidaturer - profile: - one: Profil - other: Profiler - short_link: - one: Snabblänk - other: Snabblänkar - attributes: - short_link: - link: Länknamn - target: Måladress - - activemodel: - attributes: - proposal: - title: Rubrik - sign_name: Ditt namn - sign_title: Din titel (valfritt) - - the_role: - role_created: Roll skapades - role_updated: Roll uppdaterades - role_deleted: Roll togs bort - section_created: Sektion skapades - section_not_created: Sektion skapades inte - section_rule_created: "Sektionsregel skapad" - section_rule_not_created: "Sektionsregel ej skapad" - section_rule_on: "Sektionsregel aktiverad" - section_rule_off: "Sektionsregel inaktiverad" - state_not_changed: "Sektionsregel ej ändraded" - section_deleted: Sektion borttagen - section_not_deleted: Sektion ej borttagen - section_rule_deleted: "Sektionsregel borttagen" - section_rule_not_deleted: "Sektionsregel ej borttagen" - access_denied: "Åtkomst nekad" - - admin: - roles: - new: - create: Skapa ny roll - name: Namn (små bokstäver) - title: Titel - description: Beskrivning - based_on_role: "Ny roll baseras på:" - role: - role_name: 'Namn:' - title: 'Titel:' - role_description: 'Beskrivning:' - delete_section: Ta bort sektion - section_delete_confirm: 'Vill du ta bort sektionen?' - rule_delete_confirm: 'Vill du ta bort regeln?' - enable: Aktivera - disable: Avaktivera - delete_rule: Ta bort regel - new_section_placeholder: Nytt sektionsnamn - create_section: Skapa ny sektion - new_rule_placeholder: Nytt namn på regel - create_rule: Skapa ny regel - role_export: "Exportera roll" - sidebar: - roles_export: "Exportera roller" - roles_import: "Importera roller" - roles_list: Lista med roller - new_role: Skapa ny roll - delete_role_confirm: 'Är du säker? Det kan vara farligt!' - roles_import_confirm: 'Det kan ändra behörigheter i ditt system, är du säker?' + password: Lösenord + username: Användarnamn + password_confirmation: Bekräfta lösenord + civic: Personnummer (10 siffror i följd) errors: format: "%{message}" @@ -126,3 +52,50 @@ sv: formats: day: "%A %d/%m" invalid-url: Inte en giltig webadress + + unauthorized: + default: Någonting blev fel (rättigheter) + manage: + all: Inte auktoriserad för att %{action} %{subject}. + user: "Inte auktoriserad för att hantera användarkonton." + update: + project: "Inte tillåten att uppdatera projektet." + new: + nomination: Du måste logga in för att kunna nominera. + + user: + settings: Kontoinställningar + + registation: + civic_check: För att kontrollera medlemskap i sektionen, sparas inte. + + helpers: + submit: + create: "Skapa %{model}" + submit: "Spara %{model}" + update: "Uppdatera %{model}" + nomination: + create: Skicka %{model} + actions: + back: Tillbaka + + elections: + orange_posts: Orangefärgade fält innebär att posten sitter i styrelsen. + green_posts: Grönfärgade fält innebär att posten väljs av studierådet. + x_posts: Poster med antal markerat med (x) anger exakt antal. + star_posts: Poster med antal * har ingen bestämd gräns. + posts_before: Poster som kommer att kunna sökas + posts_during: Poster som kan sökas + posts_after: Poster som inte längre kan sökas + get_in_touch: Ser något konstigt ut eller blir det fel? Hör av dig till + + nominations: + thank_you: Tack för din Nominering. + status_after: Det går endast att nominera till poster som inte väljs på Terminsmötet. + + candidates: + similar_candidate: har redan en likadan kandidatur. + + posts: + already_have_post: har redan posten. + limited: för många har posten. diff --git a/config/routes.rb b/config/routes.rb index 2ea047523..dd9a3421b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,5 @@ Fsek::Application.routes.draw do - resources :constants - post "githook" => "githook#index" get "githook/dev" => "githook#dev" get "githook/master" => "githook#master" @@ -29,16 +27,13 @@ get 'logga_in' => 'devise/sessions#new', as: :new_user_session post 'logga_in' => 'devise/sessions#create', as: :user_session delete 'logga_ut' => 'devise/sessions#destroy', as: :destroy_user_session - patch 'anvandare/redigera' => 'users#change_role', as: :change_role end get 'anvandare' => 'users#index', as: :users # Scope to change urls to swedish scope path_names: {new: 'ny', edit: 'redigera'} do - - resources :notices - + resources :constants scope :hilbertcafe do namespace :admin do @@ -83,18 +78,21 @@ resources :menus, path: :meny, except: :show + resources :pages, path: :sida do + resources :page_elements, path: :element, on: :member, except: :show + end + resources :posts, path: :poster, only: :index do get :display, on: :member get :collapse, on: :collection + patch :add_profile, on: :collection + patch :remove_profile, on: :collection end resources :councils, path: :utskott do resources :posts, path: :poster do patch :remove_profile, on: :member - patch :add_profile_username, on: :member - end - resource :page, path: :sida do - resources :page_elements, path: :element, on: :member + patch :add_profile, on: :collection end end @@ -105,6 +103,7 @@ end resources :profiles, path: :profil do + patch :search, on: :collection patch :remove_post, on: :member get :avatar, on: :member end @@ -126,29 +125,30 @@ get :candidates, path: :kandideringar, on: :member end end - resources :elections, path: :val, only: :index - namespace :election, path: :val do - resources :nominations, path: :nominera, only: [:create] do - get '', action: :new, on: :collection, as: :new + resources :elections, path: :val, only: :index do + collection do + resources :nominations, controller: 'elections/nominations', + path: :nominera, only: [:create] do + get '', action: :new, on: :collection, as: :new + end + resources :candidates, controller: 'elections/candidates', + path: :kandidera, except: [:edit] end - resources :candidates, path: :kandidera, except: [:edit] - end resources :albums, path: :galleri do - post :edit, on: :member - get :settings, path: :installningar, on: :collection + #post :edit, on: :member + #get :settings, path: :installningar, on: :collection get :upload_images, path: :ladda_upp, on: :member patch :upload_images, path: :ladda_upp, on: :member - delete :destroy_images, path: :ta_bort_bilder, on: :member - post :settings, path: :installningar, on: :collection - post '', on: :member, action: :show + #delete :destroy_images, path: :ta_bort_bilder, on: :member + #post :settings, path: :installningar, on: :collection + #post '', on: :member, action: :show resources :images, path: :bilder, except: [:new] end end - post '' => 'albums#index', as: :index_albums - resources :short_links, except: [ :show, :update, :edit ] do + resources :short_links, except: [:show, :update, :edit] do collection do get 'go' => 'short_links#go' get 'check' => 'short_links#check' diff --git a/db/migrate/20150331104855_add_fields_to_page.rb b/db/migrate/20150331104855_add_fields_to_page.rb new file mode 100644 index 000000000..145936da4 --- /dev/null +++ b/db/migrate/20150331104855_add_fields_to_page.rb @@ -0,0 +1,9 @@ +class AddFieldsToPage < ActiveRecord::Migration + def change + add_column :pages, :url, :string + add_column :pages, :visible, :boolean + add_column :pages, :title, :string + add_index :pages, :url + add_index :pages, :council_id + end +end diff --git a/db/migrate/20150331104940_change_president_columns_councils.rb b/db/migrate/20150331104940_change_president_columns_councils.rb new file mode 100644 index 000000000..6ec60b4d8 --- /dev/null +++ b/db/migrate/20150331104940_change_president_columns_councils.rb @@ -0,0 +1,8 @@ +class ChangePresidentColumnsCouncils < ActiveRecord::Migration + def change + remove_column :councils, :president, :integer + remove_column :councils, :vicepresident, :integer + add_column :councils, :president_id, :integer + add_column :councils, :vicepresident_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6691aa50f..d4f3cdf2a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do +ActiveRecord::Schema.define(version: 20150331104940) do create_table "album_categories", force: :cascade do |t| t.string "name", limit: 255 @@ -40,14 +40,6 @@ t.integer "photo_category_id", limit: 4 end - create_table "albums_categories", id: false, force: :cascade do |t| - t.integer "album_id", limit: 4 - t.integer "category_id", limit: 4 - end - - add_index "albums_categories", ["album_id", "category_id"], name: "index_albums_categories_on_album_id_and_category_id", unique: true, using: :btree - add_index "albums_categories", ["category_id"], name: "index_albums_categories_on_category_id", using: :btree - create_table "albums_images", id: false, force: :cascade do |t| t.integer "album_id", limit: 4 t.integer "image_id", limit: 4 @@ -82,11 +74,6 @@ t.datetime "updated_at" end - create_table "cafe_works_councils", id: false, force: :cascade do |t| - t.integer "cafe_work_id", limit: 4 - t.integer "council_id", limit: 4 - end - create_table "candidates", force: :cascade do |t| t.integer "post_id", limit: 4 t.integer "profile_id", limit: 4 @@ -104,15 +91,6 @@ add_index "candidates", ["post_id"], name: "index_candidates_on_post_id", using: :btree add_index "candidates", ["profile_id"], name: "index_candidates_on_profile_id", using: :btree - create_table "categories", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 - t.string "typ", limit: 255 - t.boolean "sub", limit: 1, default: false - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "constants", force: :cascade do |t| t.string "name", limit: 255 t.string "value", limit: 255 @@ -134,8 +112,6 @@ t.string "title", limit: 255 t.string "url", limit: 255 t.text "description", limit: 65535 - t.integer "president", limit: 4 - t.integer "vicepresident", limit: 4 t.string "logo_file_name", limit: 255 t.string "logo_content_type", limit: 255 t.integer "logo_file_size", limit: 4 @@ -144,6 +120,8 @@ t.datetime "created_at" t.datetime "updated_at" t.integer "contact_id", limit: 4 + t.integer "president_id", limit: 4 + t.integer "vicepresident_id", limit: 4 end create_table "documents", force: :cascade do |t| @@ -185,25 +163,6 @@ t.integer "post_id", limit: 4 end - create_table "email_accounts", force: :cascade do |t| - t.integer "profile_id", limit: 4 - t.string "email", limit: 255 - t.string "title", limit: 255 - t.boolean "active", limit: 1 - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "emails", force: :cascade do |t| - t.integer "email_account_id", limit: 4 - t.string "receiver", limit: 255 - t.string "subject", limit: 255 - t.text "message", limit: 65535 - t.boolean "copy", limit: 1 - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "events", force: :cascade do |t| t.string "title", limit: 255 t.string "author", limit: 255 @@ -245,16 +204,6 @@ t.integer "subcategory_id", limit: 4 end - create_table "lists", force: :cascade do |t| - t.string "category", limit: 255 - t.string "name", limit: 255 - t.string "string1", limit: 255 - t.integer "int1", limit: 4 - t.boolean "bool1", limit: 1 - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "menus", force: :cascade do |t| t.string "location", limit: 255 t.integer "index", limit: 4 @@ -329,8 +278,14 @@ t.datetime "created_at" t.datetime "updated_at" t.integer "council_id", limit: 4 + t.string "url", limit: 255 + t.boolean "visible", limit: 1 + t.string "title", limit: 255 end + add_index "pages", ["council_id"], name: "index_pages_on_council_id", using: :btree + add_index "pages", ["url"], name: "index_pages_on_url", using: :btree + create_table "permission_posts", force: :cascade do |t| t.integer "permission_id", limit: 4 t.integer "post_id", limit: 4 @@ -354,21 +309,6 @@ t.datetime "updated_at" end - create_table "phrasing_phrase_versions", force: :cascade do |t| - t.integer "phrasing_phrase_id", limit: 4 - t.text "value", limit: 65535 - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "phrasing_phrases", force: :cascade do |t| - t.string "locale", limit: 255 - t.string "key", limit: 255 - t.text "value", limit: 65535 - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "posts", force: :cascade do |t| t.string "title", limit: 255 t.integer "limit", limit: 4, default: 0 @@ -423,14 +363,11 @@ t.datetime "created_at" t.datetime "updated_at" t.text "comment", limit: 65535 - t.string "status", limit: 255, default: "Ej bestämd" + t.string "status", limit: 255, default: "Ej bestämd" t.boolean "service", limit: 1, default: false t.string "access_code", limit: 255 end - add_index "rents", ["d_from"], name: "index_rents_on_d_from", using: :btree - add_index "rents", ["d_til"], name: "index_rents_on_d_til", using: :btree - create_table "roles", force: :cascade do |t| t.string "name", limit: 255, null: false t.string "title", limit: 255, null: false diff --git a/lib/tasks/permissions.rake b/lib/tasks/permissions.rake index eb8d43e31..6e512f5aa 100644 --- a/lib/tasks/permissions.rake +++ b/lib/tasks/permissions.rake @@ -36,30 +36,30 @@ end #this method returns the cancan action for the action passed. def eval_cancan_action(action) case action.to_s - when 'index' - name = 'list' - cancan_action = 'index' #let the cancan action be the actual method name - action_desc = I18n.t(:list) - when 'new', 'create' - name = 'create and update' - cancan_action = 'create' - action_desc = I18n.t :create - when 'show' - name = 'view' - cancan_action = 'view' - action_desc = I18n.t :view - when 'edit', 'update' - name = 'create and update' - cancan_action = 'update' - action_desc = I18n.t :update - when 'delete', 'destroy' - name = 'delete' - cancan_action = 'destroy' - action_desc = I18n.t :destroy - else - name = action.to_s - cancan_action = action.to_s - action_desc = 'Other: ' < cancan_action + when 'index' + name = 'list' + cancan_action = 'index' #let the cancan action be the actual method name + action_desc = I18n.t(:list) + when 'new', 'create' + name = 'create and update' + cancan_action = 'create' + action_desc = I18n.t :create + when 'show' + name = 'view' + cancan_action = 'view' + action_desc = I18n.t :view + when 'edit', 'update' + name = 'create and update' + cancan_action = 'update' + action_desc = I18n.t :update + when 'delete', 'destroy' + name = 'delete' + cancan_action = 'destroy' + action_desc = I18n.t :destroy + else + name = action.to_s + cancan_action = action.to_s + action_desc = 'Other: ' < cancan_action end return name, cancan_action end diff --git a/lib/tasks/tests_data.rake b/lib/tasks/tests_data.rake index 5a2cc9eb2..2d304885b 100644 --- a/lib/tasks/tests_data.rake +++ b/lib/tasks/tests_data.rake @@ -1,9 +1,10 @@ -namespace :load_database do +namespace :db do desc 'Loads some stuff into the database for local testing' - task(populate: :environment) do + task(populate_test: :environment) do # Councils pryl = Council.find_or_create_by!(title: 'Prylmästeriet', url: 'pryl', description: 'Detta är Prylmästeriet', public: true) + sexm = Council.find_or_create_by!(title: 'Sexmästeriet', url: 'sex', description: 'Detta är Sexmästeriet', public: true) cafem = Council.find_or_create_by!(title: 'Cafemästeriet', @@ -44,7 +45,7 @@ namespace :load_database do # Permissions Rake::Task['permissions:load'].invoke perm_admin = Permission.find_or_create_by!(subject_class: :all, action: :manage) - perm_nyckelpiga = Permission.find_or_create_by!(subject_class: :cafe_work, action: :nyckelpiga) + perm_nyckelpiga = Permission.find_or_create_by!(subject_class: 'CafeWork', action: :nyckelpiga) # Give spindelman admin PermissionPost.find_or_create_by!(permission: perm_admin, post: spindel) PermissionPost.find_or_create_by!(permission: perm_nyckelpiga, post: nyckelpiga) @@ -83,5 +84,19 @@ namespace :load_database do link: '/bil', index: 20, visible: true, turbolinks: false) Menu.find_or_create_by!(location: 'För medlemmar', name: 'Hilbertcafé', link: '/hilbertcafe', index: 30, visible: true, turbolinks: false) + + # Notice + Notice.find_or_create_by!(FactoryGirl.attributes_for(:notice)) + Notice.find_or_create_by!(FactoryGirl.attributes_for(:notice)) + + # Election + election = Election.find_or_initialize_by(title: 'Vårterminsmöte', + url: 'vt-15', visible: true ) + election.update(start: Time.zone.now - 2.days, + end: Time.zone.now + 5.days) + Post.all do |p| + election.posts << p + end + election.save end end diff --git a/spec/controllers/cafe_works_controller_spec.rb b/spec/controllers/cafe_works_controller_spec.rb index 8c04859df..3474e0b53 100644 --- a/spec/controllers/cafe_works_controller_spec.rb +++ b/spec/controllers/cafe_works_controller_spec.rb @@ -192,7 +192,10 @@ context 'not allowed' do it 'does not work' do get :nyckelpiga - response.should have_http_status(:forbidden) + + # Changed the response to AccessDenied + #response.should have_http_status(:forbidden) + response.should redirect_to :new_user_session end end context 'allowed' do diff --git a/spec/controllers/constants_controller_spec.rb b/spec/controllers/constants_controller_spec.rb index 3167e5206..1a3d01075 100644 --- a/spec/controllers/constants_controller_spec.rb +++ b/spec/controllers/constants_controller_spec.rb @@ -5,7 +5,8 @@ it 'returns http forbidden' do get :index - response.should have_http_status(:forbidden) + #response.should have_http_status(:forbidden) + response.should redirect_to :new_user_session end end diff --git a/spec/controllers/election/candidates_controller_spec.rb b/spec/controllers/elections/candidates_controller_spec.rb similarity index 88% rename from spec/controllers/election/candidates_controller_spec.rb rename to spec/controllers/elections/candidates_controller_spec.rb index f2002d67f..9140db9f5 100644 --- a/spec/controllers/election/candidates_controller_spec.rb +++ b/spec/controllers/elections/candidates_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Election::CandidatesController, type: :controller do +RSpec.describe Elections::CandidatesController, type: :controller do # Build an election let(:election) { create(:election) } before(:each) do @@ -20,14 +20,16 @@ it 'returns http forbidden' do get :index - response.should have_http_status(:forbidden) + # Changed the AccessDenied action to redirect + #response.should have_http_status(:forbidden) + response.should redirect_to(:new_user_session) end end describe 'GET #show' do it 'diplays an error flash' do get :show, id: candidate.id - flash[:error].should_not be_empty + flash[:alert].should_not be_empty end end end @@ -82,7 +84,7 @@ end it 'creates candidate and redirects to candidate' do post :create, candidate: attributes_for(:candidate, post_id: search_post.id) - expect(response).to redirect_to([:election, Candidate.last]) + expect(response).to redirect_to(Candidate.last) end end @@ -100,12 +102,12 @@ it 'assigns the requested candidate as @candidate' do patch :update, id: candidate.to_param, candidate: change_attributes - expect(assigns(:candidate)).to eq(candidate) + assigns(:candidate).should eq(candidate) end it 'redirects to the candidate' do patch :update, id: candidate.to_param, candidate: change_attributes - expect(response).to redirect_to([:election, candidate]) + response.should redirect_to(candidate) end end @@ -132,7 +134,7 @@ it 'redirects to the candidates list' do delete :destroy, id: candidate.to_param - expect(response).to redirect_to(election_candidates_path) + expect(response).to redirect_to(candidates_path) end end end diff --git a/spec/factories/elections.rb b/spec/factories/elections.rb index db2043207..e68508961 100644 --- a/spec/factories/elections.rb +++ b/spec/factories/elections.rb @@ -5,5 +5,9 @@ start { Time.zone.now - 2.days } election.end { Time.zone.now + 5.days } visible true + description + candidate_mail_star { generate(:email) } + mail_link { generate(:email) } + mail_styrelse_link { generate(:email) } end end diff --git a/spec/factories/notice.rb b/spec/factories/notice.rb new file mode 100644 index 000000000..c597f19aa --- /dev/null +++ b/spec/factories/notice.rb @@ -0,0 +1,11 @@ +# encoding: UTF-8 +FactoryGirl.define do + factory :notice do + title + description + public true + d_publish { Time.zone.now } + d_remove { Time.zone.now + 10.days } + sort { rand(10..100) } + end +end diff --git a/spec/factories/posts.rb b/spec/factories/posts.rb index 177e3669c..0ec8b6d1a 100644 --- a/spec/factories/posts.rb +++ b/spec/factories/posts.rb @@ -3,6 +3,7 @@ factory :post do title description + elected_by { ['Studierådet','Terminsmötet'].sample} limit { rand(1..3) } recLimit { rand(3..7) } end diff --git a/spec/factories/role.rb b/spec/factories/role.rb deleted file mode 100644 index b8e58c265..000000000 --- a/spec/factories/role.rb +++ /dev/null @@ -1,17 +0,0 @@ -FactoryGirl.define do - factory :role do - #initialize_with { Role.where(title: 'role').first_or_create } - name 'A role' - title 'role' - description 'A role description' - the_role '' - end - - factory :admin_role, class: Role do - #initialize_with { Role.where(title: 'admin').first_or_create } - name 'The admin role' - title 'admin' - description 'An admin' - the_role '{"system":{"administrator":true}}' - end -end diff --git a/spec/features/admin_notice_spec.rb b/spec/features/admin_notice_spec.rb new file mode 100644 index 000000000..60ed243ba --- /dev/null +++ b/spec/features/admin_notice_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' +feature 'admin tries to login' do + let(:user) { create(:admin) } + let(:notice) { build(:notice) } + scenario 'they get alert with text "Loggade in"' do + visit '/logga_in' + fill_in 'user_username', with: user.username + fill_in 'user_password', with: '12345678' + click_button 'Logga in' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('Loggade in.') # Verify that the alert states we are signed in + # TODO Include warden to stub login + #login_as(user, scope: :user) + + # Test notice + visit notices_path + find('h2#notice-headline').text.should include('Notiser') + find(:linkhref, new_notice_path).click + fill_in 'notice_title', with: notice.title + fill_in 'notice_description', with: notice.description + find(:css, "#notice_public").set(notice.public) + fill_in 'notice[d_publish]', with: notice.d_publish + fill_in 'notice[d_remove]', with: notice.d_remove + fill_in 'notice_sort', with: notice.sort + find('#submit-notice').click + + page.should have_css('div.alert.alert-info') + find('div.alert.alert-info').text.should include(%(#{I18n.t(:notice)} #{I18n.t(:success_create)})) + end +end diff --git a/spec/features/admin_rent_spec.rb b/spec/features/admin_rent_spec.rb new file mode 100644 index 000000000..6e2536abf --- /dev/null +++ b/spec/features/admin_rent_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' +feature 'admin tries to login' do + let(:user) { create(:admin) } + let(:council) { create(:council) } + let(:rent) { build(:rent, council: council) } + before do + council + end + scenario 'logins succeds, goes to rent, creates new rent' do + visit '/logga_in' + fill_in 'user_username', with: user.username + fill_in 'user_password', with: '12345678' + click_button 'Logga in' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('Loggade in.') # Verify that the alert states we are signed in + # TODO Include warden to stub login + #login_as(user, scope: :user) + + # Test notice + visit admin_car_path + find('h1').text.should include('F-bilen') + find(:linkhref, new_admin_rent_path).click + fill_in 'rent_name', with: rent.name + fill_in 'rent_lastname', with: rent.lastname + fill_in 'rent_email', with: rent.email + fill_in 'rent_phone', with: rent.phone + fill_in 'rent_d_from', with: rent.d_from.to_s + fill_in 'rent_d_til', with: rent.d_til.to_s + select(rent.council, from: 'rent_council') + select('Bekräftad', from: 'rent_status') + find('#rent-submit').click + + # TODO + # Add confirmation of creation + end +end diff --git a/spec/features/login_visit_election.rb b/spec/features/login_visit_election.rb new file mode 100644 index 000000000..73208e68e --- /dev/null +++ b/spec/features/login_visit_election.rb @@ -0,0 +1,42 @@ +require 'rails_helper' +feature 'not logged in' do + let(:user) { create(:user) } + let(:election) { create(:election) } + let(:council) { create(:council) } + let(:post) { create(:post, council: council, elected_by: 'Terminsmötet') } + before(:each) do + allow(Election).to receive(:current).and_return(election) + end + before do + election + election.posts << post + end + scenario 'they try to visit election' do + visit elections_path + page.should have_css('h1#election-title') + find('h1#election-title').text.should include(election.title) + + # Try nomination page + visit new_nominations_path + page.should have_css('div.alert-danger') + find('div.alert-danger').text.should include(I18n.t('unauthorized.new.nomination')) + fill_in 'user_username', with: user.username + fill_in 'user_password', with: '12345678' + click_button 'Logga in' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include(I18n.t('devise.sessions.signed_in')) + + + visit new_nominations_path + find('h1').text.should include('Nominering') # Verify that the alert states we are signed in + + + fill_in 'nomination_name', with: 'David Wessman' + fill_in 'nomination_email', with: 'd.wessman@fsektionen.se' + select(post, from: 'nomination_post') + fill_in 'nomination_motivation', with: 'Foo' + find('#nomination-submit').click + page.should have_css('div#status') + find('div#status').text.should include() # Verify that the alert states we are signed in + end +end diff --git a/spec/features/visit_a_council.rb b/spec/features/visit_a_council.rb new file mode 100644 index 000000000..870381fe3 --- /dev/null +++ b/spec/features/visit_a_council.rb @@ -0,0 +1,13 @@ +require 'rails_helper' +feature 'not logged in' do + let(:user) { create(:user) } + let(:council) { create(:council, :with_page, public: true) } + scenario 'they get alert with text "Loggade in"' do + visit %(/utskott/#{council.to_param}) + fill_in 'user_username', with: user.username + fill_in 'user_password', with: '12345678' + click_button 'Logga in' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('Loggade in.') # Verify that the alert states we are signed in + end +end diff --git a/spec/features/visit_cafe_work.rb b/spec/features/visit_cafe_work.rb new file mode 100644 index 000000000..640906d1f --- /dev/null +++ b/spec/features/visit_cafe_work.rb @@ -0,0 +1,22 @@ +require 'rails_helper' +feature 'logged in' do + let(:user) { create(:user) } + let(:cafe_work) { create(:cafe_work)} + scenario 'they can sign up to work' do + visit '/logga_in' + fill_in 'user_username', with: user.username + fill_in 'user_password', with: '12345678' + click_button 'Logga in' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('Loggade in.') # Verify that the alert states we are signed in + + visit %(/hilbertcafe/jobb/#{cafe_work.id}) + fill_in 'cafe_work_name', with: user.profile.name + fill_in 'cafe_work_lastname', with: user.profile.lastname + fill_in 'cafe_work_email', with: user.email + fill_in 'cafe_work_phone', with: user.profile.phone + click_button 'Spara' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('du arbetar!') # Verify that the alert states we are signed in + end +end diff --git a/spec/features/visit_cafe_work_with_authorize.rb b/spec/features/visit_cafe_work_with_authorize.rb new file mode 100644 index 000000000..1ab0f2c98 --- /dev/null +++ b/spec/features/visit_cafe_work_with_authorize.rb @@ -0,0 +1,15 @@ +require 'rails_helper' +feature 'not logged in' do + let(:cafe_work) { create(:cafe_work)} + let(:attributes) { attributes_for(:profile)} + scenario 'they can sign up to work' do + visit %(/hilbertcafe/jobb/#{cafe_work.id}) + fill_in 'cafe_work_name', with: attributes[:name] + fill_in 'cafe_work_lastname', with: attributes[:lastname] + fill_in 'cafe_work_email', with: attributes[:phone] + fill_in 'cafe_work_phone', with: attributes[:name] + click_button 'Spara' + page.should have_css('div.alert.alert-info') # Verify we get an alert + find('div.alert.alert-info').text.should include('du arbetar!') # Verify that the alert states we are signed in + end +end diff --git a/spec/models/cafe_work_spec.rb b/spec/models/cafe_work_spec.rb index 6983874f6..f20373475 100644 --- a/spec/models/cafe_work_spec.rb +++ b/spec/models/cafe_work_spec.rb @@ -20,7 +20,7 @@ it { should validate_presence_of(:lv) } it { should validate_inclusion_of(:pass).in_range(1..4) } it { should validate_inclusion_of(:lp).in_range(1..4) } - it { should validate_inclusion_of(:lv).in_range(1..7) } + it { should validate_inclusion_of(:lv).in_range(1..20) } context 'if has_worker' do before { allow(subject).to receive(:has_worker?).and_return(true) } diff --git a/spec/models/candidate_spec.rb b/spec/models/candidate_spec.rb index d64ea8e49..8342277e5 100644 --- a/spec/models/candidate_spec.rb +++ b/spec/models/candidate_spec.rb @@ -6,44 +6,43 @@ end # Lazily loaded to ensure it's only used when it's needed - let(:cand) { build(:candidate) } + subject(:cand) { build(:candidate) } let(:saved) { create(:candidate) } describe 'ActiveModel validations' do # Basic validations it do - val = validate_uniqueness_of(:profile_id). - scoped_to(:post_id, :election_id). - with_message('har redan en likadan kandidatur'). - on(:create) - expect(cand).to val + cand.should validate_uniqueness_of(:profile_id). + scoped_to(:post_id, :election_id). + with_message(I18n.t('candidates.similar_candidate')). + on(:create) end end - it { expect(cand).to validate_presence_of(:name) } - it { expect(cand).to validate_presence_of(:lastname) } - it { expect(cand).to validate_presence_of(:stil_id) } - it { expect(cand).to validate_presence_of(:email) } - it { expect(cand).to validate_presence_of(:phone) } - it { expect(cand).to validate_presence_of(:election) } - it { expect(cand).to validate_presence_of(:profile) } - it { expect(cand).to validate_presence_of(:post).on(:create) } + it { should validate_presence_of(:name) } + it { should validate_presence_of(:lastname) } + it { should validate_presence_of(:stil_id) } + it { should validate_presence_of(:email) } + it { should validate_presence_of(:phone) } + it { should validate_presence_of(:election) } + it { should validate_presence_of(:profile) } + it { should validate_presence_of(:post).on(:create) } describe 'ActiveRecord associations' do # Associations - it { expect(cand).to belong_to(:election) } - it { expect(cand).to belong_to(:post) } - it { expect(cand).to belong_to(:profile) } + it { should belong_to(:election) } + it { should belong_to(:post) } + it { should belong_to(:profile) } end context 'callbacks' do describe 'public instance methods' do context 'responds to its methods' do - it { expect(saved).to respond_to(:send_email) } - it { expect(saved).to respond_to(:prepare) } - it { expect(saved).to respond_to(:editable?) } - it { expect(saved).to respond_to(:p_url) } - it { expect(saved).to respond_to(:owner?) } + it { saved.should respond_to(:send_email) } + it { saved.should respond_to(:prepare) } + it { saved.should respond_to(:editable?) } + it { saved.should respond_to(:p_url) } + it { saved.should respond_to(:owner?) } end end end diff --git a/spec/models/council_spec.rb b/spec/models/council_spec.rb new file mode 100644 index 000000000..e69de29bb