From c62b3b34dd50e11df524e6e1a9a84e221c0ae1eb Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sun, 21 Jun 2015 00:03:01 +0200 Subject: [PATCH] AutoCommit Son Jun 21 00:03:01 CEST 2015 --- app/assets/stylesheets/layout.css.scss | 7 +- app/controllers/lvas_controller.rb | 3 + app/models/beispiel.rb | 10 +- .../themes/blue2/beispiele/_beispiel.html.erb | 7 +- app/views/themes/blue2/lvas/show.html.erb | 143 ++++++++++++++++++ lib/flagable.rb | 9 +- 6 files changed, 168 insertions(+), 11 deletions(-) create mode 100755 app/views/themes/blue2/lvas/show.html.erb diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 1f5a328..7c655ed 100755 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -205,4 +205,9 @@ form.inline input { form.inline { float:clear; } -@import 'tinymce'; \ No newline at end of file +@import 'tinymce'; + +a.flag-true { color: $color_schema_3_dark} +a.flag-true.flag-goodquality-true { color: green} + +a.flag-false { color: #CCC} \ No newline at end of file diff --git a/app/controllers/lvas_controller.rb b/app/controllers/lvas_controller.rb index 44f1a9b..ac8b380 100755 --- a/app/controllers/lvas_controller.rb +++ b/app/controllers/lvas_controller.rb @@ -47,6 +47,9 @@ class LvasController < ApplicationController def show @lva = Lva.find_by_id(params[:id]) @beispiel=Beispiel.new + @beispiele = @lva.beispiele.not_flag_badquality.not_flag_delete.order(:datum).accessible_by(current_ability, :show) + @beispiele_badQ = @lva.beispiele.flag_badquality.not_flag_delete.order(:datum).accessible_by(current_ability, :show) + @beispiele_deleted = @lva.beispiele.flag_delete.order(:datum).accessible_by(current_ability, :show) @toolbar_elements =[] @toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.manage'),:path => verwalten_lva_path(@lva)} if can? :verwalten, @lva @crawlobjects = @lva.crawlobjects.roots.accessible_by(current_ability) diff --git a/app/models/beispiel.rb b/app/models/beispiel.rb index 5811ac8..24a0f7b 100755 --- a/app/models/beispiel.rb +++ b/app/models/beispiel.rb @@ -17,9 +17,13 @@ class Beispiel < ActiveRecord::Base acts_as_votable acts_as_flagable belongs_to :lva - FLAG_ICONS = {"badquality"=>"fa fa-flag", "delete"=>"icon-trash"} - - mount_uploader :beispieldatei, AttachmentUploader + FLAG_ICONS = {"badquality"=>"fa fa-flag","goodquality"=>"fa fa-flag", "delete"=>"fa fa-trash"} + scope :not_flag_badquality, ->{where("flag_badquality IS NULL OR flag_badquality=?",false)} + scope :flag_badquality, ->{where("flag_badquality=?",true)} + scope :not_flag_delete, ->{where("flag_delete IS NULL OR flag_delete=?",false)} + scope :flag_delete, ->{where("flag_delete=?",true)} + + mount_uploader :beispieldatei, AttachmentUploader validates :beispieldatei, :presence => true validates :name, :presence => true validates :lva_id, :presence => true diff --git a/app/views/themes/blue2/beispiele/_beispiel.html.erb b/app/views/themes/blue2/beispiele/_beispiel.html.erb index 2fd1ed6..5f8ca83 100644 --- a/app/views/themes/blue2/beispiele/_beispiel.html.erb +++ b/app/views/themes/blue2/beispiele/_beispiel.html.erb @@ -7,9 +7,10 @@ <%= (beispiel.beispieldatei.size/1024.0).round(2).to_s %>KiB
-<% fi = {"badquality"=>"fa fa-flag", "delete"=>"fa fa-trash"} %> - <%= flag_link(beispiel, "badquality", ff_icon(fi["badquality"]))%> - <%= flag_link(beispiel, "delete", ff_icon(fi["delete"]))%> + <%= flag_link(beispiel, "goodquality")%> + + <%= flag_link(beispiel, "badquality")%> + <%= flag_link(beispiel, "delete")%> <%= if can?(:like, beispiel) diff --git a/app/views/themes/blue2/lvas/show.html.erb b/app/views/themes/blue2/lvas/show.html.erb new file mode 100755 index 0000000..d5710ba --- /dev/null +++ b/app/views/themes/blue2/lvas/show.html.erb @@ -0,0 +1,143 @@ +<%= content_for :header do %> +Fetsite - <%= @lva.full_name %> +<% set_meta_tags :og => { + :url=>lva_path(:theme=>nil) } +%> +<%= display_meta_tags %> +<% end %> +
+
+ <%= render 'studien/tabs'%> +

<%= notice %>

+ +
+
+ <%= render 'layouts/pretty_toolbar' %> +
+
+ +
+
+

<%= @lva.full_name %>

+ + +
+

<%= I18n.t('lva.pruefungsinfo')%>

+
+ <%= @lva.pruefungsinformation.to_s.html_safe %> +
+ +

<%= I18n.t('lva.lernaufwand')%>

+
+ <%= @lva.lernaufwand %> +
+ +

<%= I18n.t('lva.desc')%>

+
+ <%= @lva.desc.to_s.html_safe %> +
+
+
+
+
+
    +
  • <%= I18n.t('lva.lvanr')%>: <%=@lva.lvanr %>
  • +
  • ECTS: <%=@lva.ects %>
  • +
  • <%= I18n.t('lva.stunden')%>: <%=@lva.stunden %>
  • +
+

<%= I18n.t('lva.module')%>

+
    + <% @lva.modul.each do |modul| %> +
  • <%= link_to modul.name , modul_path(modul)%> +
      + <% modul.modulgruppen.each do |g| %> + +
    • <%= link_to g.studium.title_context , studium_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)
    • + <% end %> +
    +
  • + + <% end %> +
+
+
+

<%= I18n.t "lecturers.lecturers" %>

+ <% @lva.lecturers.each do |lec| %> + <%= render :partial=>'lecturers/lec_lva', :object=>lec %> + + <% end %> +
+
+
+ + +
+
+ +

<%= I18n.t("lva.bspe") %>

+

+ <%= I18n.t("lva.ratebsp")%> + <%= link_to ffi1_icon("facebook1") + I18n.t('home.fblogin'), user_omniauth_authorize_path(:facebook) ,class: :linkbox %> +

+ <%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %> + <% @beispiele.each do |b| %> + <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + b.updated_at.try(:utc).try(:to_s)) do %> + <%= render b%> + <% end %> + <% end %> +

Bad Quality or Outdated

+ <% @beispiele_badQ.each do |b| %> + <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + b.updated_at.try(:utc).try(:to_s)) do %> + <%= render b%> + <% end %> + <% end %> +

Trash

+ <% @beispiele_deleted.each do |b| %> + <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s +"_"+ can?(:flag,b).to_s+ "_" + b.updated_at.try(:utc).try(:to_s)) do %> + <%= render b%> + <% end %> + <% end %> + +
+ +
+ +
+
+ <% unless @lva.nlinks.empty? %> +

<%= I18n.t("rubrik.title") %>

+ <% @lva.nlinks.each do |l| %> + <%= render l.neuigkeit %> + <% end %> + <% end %> + +
+
+ <% cache("lva_beispiel_form_bulk_"+@lva.id.to_s+I18n.locale.to_s+@lva.updated_at.to_i.to_s) do %> +
+
+ <%= render 'beispiele/form_bulk' %> +
+
+ + <% end %> + <% unless @crawlobjects.nil? %> +
+
+ <% @crawlobjects.each do |co| %> + <%= render co %> + <% end %> +
+
+ <% end %> + +
+
+ diff --git a/lib/flagable.rb b/lib/flagable.rb index 5add5e0..01aabff 100644 --- a/lib/flagable.rb +++ b/lib/flagable.rb @@ -16,7 +16,7 @@ module Flagable module LocalInstanceMethods def flag - fi = {"badquality"=>"fa fa-flag", "delete"=>"fa fa-trash"} + fi = controller_name.classify.constantize::FLAG_ICONS @obj=controller_name.classify.constantize.find(params[:id]) lflag=("flag_"+params[:flag]).to_sym @@ -58,11 +58,12 @@ module Flagable end module FlagableHelper - def flag_link(obj, flag, text) + def flag_link(obj, flag, text="") flag=flag.to_s + fi = obj.class::FLAG_ICONS value=obj.send("flag_"+flag) - color=(value) ? "red" :"grey" - link_to text, flag_beispiel_path(obj,{flag: flag, value: !value, theme: nil, locale: nil}), remote: true, style:("color:" +color ), id: obj.flaglinkid(flag) + cstyle=(value) ? "true" :"false" + link_to ff_icon(fi[flag]), flag_beispiel_path(obj,{flag: flag, value: !value, theme: nil, locale: nil}), remote: true, class:("flag-"+cstyle +" flag-"+flag + "-"+cstyle ), id: obj.flaglinkid(flag) end end end