Skip to content

Commit

Permalink
Merge pull request #683 from coopdevs/develop
Browse files Browse the repository at this point in the history
Release v4.1.0
  • Loading branch information
markets authored Apr 10, 2023
2 parents 2157c4d + 264a82d commit 8f66df1
Show file tree
Hide file tree
Showing 25 changed files with 125 additions and 61 deletions.
14 changes: 10 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@
# Your local .env file is added to .gitignore and
# wont be uploaded to the repo.


# database setup
# Database setup
DATABASE_USER=postgres
DATABASE_NAME=timeoverflow_development

# host part of the url for mail links:
# Host part of the url for mail links:
MAIL_LINK_HOST=localhost:3000
MAIL_LINK_PROTO=http

# a list of emails for superadmin users
# Email provider
SMTP_PASSWORD=XXXXXXXX
SMTP_DOMAIN=www.timeoverflow.org
SMTP_USER_NAME=[email protected]
SMTP_ADDRESS=smtp.mailgun.org
SMTP_PORT=587

# List of emails for superadmin users
ADMINS="[email protected]"

# AWS settings
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TimeOverflow
[![View performance data on Skylight](https://badges.skylight.io/problem/grDTNuzZRnyu.svg)](https://oss.skylight.io/app/applications/grDTNuzZRnyu)
[![View performance data on Skylight](https://badges.skylight.io/typical/grDTNuzZRnyu.svg)](https://oss.skylight.io/app/applications/grDTNuzZRnyu)
[![Build Status](https://github.com/coopdevs/timeoverflow/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/coopdevs/timeoverflow/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/maintainability)](https://codeclimate.com/github/coopdevs/timeoverflow/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/test_coverage)](https://codeclimate.com/github/coopdevs/timeoverflow/test_coverage)
Expand Down
7 changes: 5 additions & 2 deletions app/admin/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
index do
id_column
column :name do |category|
"#{tag.span(nil, class: "glyphicon glyphicon-#{category.icon_name}")} #{category.name}".html_safe
"#{category_icon(category)} #{category.name}".html_safe
end
actions
end
Expand All @@ -17,9 +17,12 @@

show do |cat|
attributes_table do
row :name do
"#{category_icon(cat)} #{cat.name}".html_safe
end
row :icon_name
row :created_at
row :updated_at
row :icon_name
row :name_translations do
render_translations(cat.name_translations)
end
Expand Down
20 changes: 20 additions & 0 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }

content title: proc { I18n.t("active_admin.dashboard") } do
columns do
panel "Global Stats", class: "global_stats_panel" do
div { "#{glyph(:home)} Time Banks <b>#{Organization.count}</b>".html_safe }
div { "#{glyph(:user)} Users <b>#{User.count}</b>".html_safe }
div { "#{glyph(:hand_up)} Offers <b>#{Offer.count}</b>".html_safe }
div { "#{glyph(:bell)} Inquiries <b>#{Inquiry.count}</b>".html_safe }
div { "#{glyph(:transfer)} Transfers <b>#{Transfer.count}</b>".html_safe }
end
end

columns do
column do
panel "Recent Organizations" do
Expand Down Expand Up @@ -32,6 +42,16 @@
end
end
end

column do
panel "Recent Petitions" do
ul do
Petition.last(5).map do |petition|
li "#{petition.user} #{glyph(:arrow_right)} #{petition.organization}".html_safe
end
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion app/admin/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
render_translations(t.title_translations)
end
row :content_translations do
render_translations(t.content_translations, "<br>")
render_translations(t.content_translations, "<hr>")
end
end
end
Expand Down
28 changes: 26 additions & 2 deletions app/admin/organization.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
ActiveAdmin.register Organization do
index do
id_column
column :name
column :name do |organization|
output = tag.p organization.name

if organization.logo.attached?
output << image_tag(organization.logo.variant(resize: "40^x"))
end

output.html_safe
end
column :created_at do |organization|
l organization.created_at.to_date, format: :long
end
column :city
column :neighborhood
column :email
column :phone
column :members do |organization|
organization.members.count
end
column :posts do |organization|
organization.posts.count
end
actions
end

show do
div do
if organization.logo.attached?
image_tag(organization.logo.variant(resize: "100^x"))
end
end
default_main_content
end

form do |f|
f.inputs do
f.input :name
Expand All @@ -23,6 +46,7 @@
f.input :address
f.input :description
f.input :public_opening_times
f.input :logo, as: :file
end
f.actions
end
Expand All @@ -47,5 +71,5 @@ def destroy
filter :neighborhood

permit_params :name, :email, :web, :phone, :city, :neighborhood,
:address, :description, :public_opening_times
:address, :description, :public_opening_times, :logo
end
4 changes: 3 additions & 1 deletion app/admin/petition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
column :user
column :organization
column :created_at
column :status
column :status do |petition|
petition.status.upcase
end
end

filter :status, as: :select, collection: -> { Petition.statuses }
Expand Down
11 changes: 8 additions & 3 deletions app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
column :organizations do |u|
u.organizations.map(&:to_s).join(", ")
end
column :posts do |u|
u.posts.count
end
actions
end

Expand All @@ -31,6 +34,7 @@
filter :username
filter :phone
filter :postcode
filter :locale

form do |f|
f.semantic_errors *f.object.errors.keys
Expand All @@ -40,9 +44,10 @@
f.input :phone
f.input :postcode
f.input :gender, as: :select, collection: User::GENDERS
f.input :locale, as: :select, collection: I18n.available_locales
end
f.inputs "Memberships" do
f.has_many :members do |m|
f.has_many :members, allow_destroy: true do |m|
m.input :organization, collection: Organization.order(id: :asc).pluck(:name, :id)
m.input :active
m.input :manager
Expand Down Expand Up @@ -78,6 +83,6 @@
end
end

permit_params :username, :email, :phone, :postcode, :gender,
members_attributes: [:organization_id, :active, :manager]
permit_params :username, :email, :phone, :postcode, :gender, :locale,
members_attributes: [:id, :organization_id, :active, :manager, :_destroy]
end
17 changes: 5 additions & 12 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ $(document).on('click', 'a[data-popup]', function(event) {
$(document).on('click', 'span.show-password', function(event) {
event.preventDefault();

var inputType = 'text';
var icon = 'visibility_off';
var input = $(this).prev('input');
var icon = $(this).find('.glyphicon');

if ($(this).hasClass('checked')) {
$(this).removeClass('checked');
inputType = 'password';
icon = 'visibility';
} else {
$(this).addClass('checked');
}

$(this).prev('input').attr('type', inputType);
$(this).find('.material-icons').html(icon);
$(input).attr('type', input[0].type === 'password' ? 'text' : 'password');
$(icon).toggleClass('glyphicon-eye-close');
$(icon).toggleClass('glyphicon-eye-open');
});

$(function() {
Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/active_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ $table-stripe-color: #f5f5f5;
@import "bootstrap-sprockets";
@import "bootstrap/variables";
@import "bootstrap/glyphicons";

.global_stats_panel div {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 5px;
font-size: 18px;

b {
font-size: 20px;
}
}
23 changes: 8 additions & 15 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ html {
padding: 0;
}

form .material-icons {
color: $form-input-glyph;
}

input {
background-color: $form-input-bg-color;
border-radius: 0.3rem;
Expand Down Expand Up @@ -450,10 +446,6 @@ label[required]::after{
}

.login-page {
.material-icons {
font-size: 3rem;
}

.checkbox {
color: $form-login-gray-text;
font-size: 1.6rem;
Expand Down Expand Up @@ -568,6 +560,7 @@ label[required]::after{

.feature-icon {
float: left;
margin-right: 2rem;
}

.features .first {
Expand All @@ -584,12 +577,6 @@ label[required]::after{
padding-top: 3.5rem;
}

.features .material-icons {
margin-right: 2rem;
position: relative;
top: 0.2rem;
}

.banner {
background: image-url('home_back.jpg') no-repeat center center;
background-size: cover;
Expand Down Expand Up @@ -671,7 +658,13 @@ label[required]::after{
}

.organization-logo {
padding-top: 120px;
padding-top: 80px;

img {
display: block;
margin: 0 auto;
max-width: 600px;
}
}

.input__password-eye {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def scoped_users
end

def user_params
fields_to_permit = %w"gender username email date_of_birth phone
alt_phone active description notifications push_notifications postcode"
fields_to_permit = %w"gender username email date_of_birth phone alt_phone active
locale description notifications push_notifications postcode"
fields_to_permit += %w"admin registration_number
registration_date" if admin?
fields_to_permit += %w"organization_id superadmin" if superadmin?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def organization_logo
return if "#{controller_name}##{action_name}".in? %w(organizations#index pages#show)

content_tag(:div, class: "row organization-logo") do
image_tag(org.logo.variant(resize: "x200^"), class: 'img-responsive center-block')
image_tag org.logo.variant(resize: "x200^")
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User < ApplicationRecord
has_many :device_tokens
has_many :petitions, dependent: :delete_all

accepts_nested_attributes_for :members
accepts_nested_attributes_for :members, allow_destroy: true

default_scope { order("users.id ASC") }
scope :actives, -> { references(:members).where(members: { active: true }) }
Expand Down
3 changes: 2 additions & 1 deletion app/services/user_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def user_from_row
email: email,
phone: phone,
alt_phone: alt_phone,
gender: gender
gender: gender,
locale: I18n.locale
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">email</i>
<%= glyph(:envelope) %>
</span>
<%= f.text_field :email, required: false, autofocus: true, placeholder: t("application.login_form.email"), class: "form-control input-lg" %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">lock</i>
<%= glyph(:lock) %>
</span>
<%= f.password_field :password, required: true, autofocus: true, placeholder: t(".new_password"), class: "form-control input-lg" %>
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">lock</i>
<%= glyph(:lock) %>
</span>
<%= f.password_field :password_confirmation, required: true, placeholder: t(".confirm_password"), oninput: "this.setCustomValidity(this.value != form.user_password.value ? '#{t(".passwords_not_match")}' : '')", class: "form-control input-lg" %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">email</i>
<%= glyph(:envelope) %>
</span>
<%= f.text_field :email, required: false, autofocus: true, placeholder: t("application.login_form.email"), class: "form-control input-lg" %>
</div>
Expand Down
Loading

0 comments on commit 8f66df1

Please sign in to comment.