tkh_mailing_list 0.9.2 → 0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fae94da3929b8e0ffbfaac55589d653bb764151
4
- data.tar.gz: 94b9bfc0c731970fcb0d5cfdcf2312f35e523883
3
+ metadata.gz: 2caf6bc1d6e75f3b4453e161d2e457e1e2f5f650
4
+ data.tar.gz: ed54427b977379f9841f9998c1c7590eb98fcf5b
5
5
  SHA512:
6
- metadata.gz: 37bc21297277d51d7d228b560bd9d4ce9e309f03ad6ea9ad70f077e1d2e4e0ac150b8a2f671cf717ce049d12c3750699a22e2c7d28b56b63d126bf1117c423bd
7
- data.tar.gz: 41f412275b7f4515a7f542b28fd16cd550254f7d617bec2bcef1e5d5979894907fe734276ba90ec8ca89b2a3eed6c440f90a993432972a5755b68586f170cb79
6
+ metadata.gz: 5cc9b34dd1067c20b7a520d6abbbc4c3889b8cb739876904bcc6c762c888008ccfaed9b1c61449229cb10ab9b7d83df3255486767b16bd40cfa773c693e4d9d6
7
+ data.tar.gz: 2b7e4afc6d5cdfe4dc0f3af22538d1815e97367b701022ba894196dad01f2ae91fe42ebde145e736548f858eafccd59c85fa0cc74d46b0bb988cc1b0aaa3b5c9
@@ -2,6 +2,12 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.10
6
+
7
+ * Added a member resource for admins to update user records. Users are scoped as members.
8
+ * Added a profile resource for users to view and edit their own info.
9
+
10
+
5
11
  ## 0.9.2
6
12
 
7
13
  * Fixed up details user form
@@ -0,0 +1,62 @@
1
+ class MembersController < ApplicationController
2
+
3
+ before_filter :authenticate, except: :show
4
+ before_filter :authenticate_with_admin, except: :show
5
+
6
+ before_action :set_member, only: [ :show, :edit, :update, :destroy ]
7
+
8
+ def index
9
+ @members = Member.by_recent.paginate(:page => params[:page], :per_page => 50)
10
+ switch_to_admin_layout
11
+ end
12
+
13
+ def show
14
+ end
15
+
16
+ def new
17
+ @member = Member.new
18
+ switch_to_admin_layout
19
+ end
20
+
21
+ def edit
22
+ switch_to_admin_layout
23
+ end
24
+
25
+ def create
26
+ @member = Member.new(member_params)
27
+ if @member.save
28
+ redirect_to @member, notice: t('members.create.notice')
29
+ else
30
+ render action: "new", warning: t('members.create.warning'), layout: 'admin'
31
+ end
32
+ end
33
+
34
+ def update
35
+ if @member.update_attributes(member_params)
36
+ redirect_to @member, notice: t('members.update.notice')
37
+ else
38
+ render action: "edit", warning: t('members.update.warning'), layout: 'admin'
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ if @member.destroy
44
+ redirect_to members_path, notice: t('members.destroy.notice')
45
+ else
46
+ redirect_to members_path, warning: t('members.destroy.warning')
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_member
54
+ @member = Member.find(params[:id])
55
+ end
56
+
57
+ # Never trust parameters from the scary internet, only allow the white list through.
58
+ def member_params
59
+ params.require(:member).permit( :email, :first_name, :last_name, :other_name, :teacher_status )
60
+ end
61
+
62
+ end
@@ -0,0 +1,37 @@
1
+ class ProfilesController < ApplicationController
2
+
3
+ before_filter :authenticate
4
+
5
+ before_action :set_profile
6
+
7
+ def show
8
+ end
9
+
10
+ def edit
11
+ end
12
+
13
+ def update
14
+ if @profile.update_attributes(profile_params)
15
+ redirect_to profile_path, notice: "<strong>Success!</strong> Your profile was updated.".html_safe
16
+ else
17
+ render action: "edit", warning: "<strong>Attention!</strong> A problem occurred while trying to update your profile. Plese try again".html_safe
18
+ end
19
+ end
20
+
21
+ def history
22
+ @activities = doer.activities.by_recent
23
+ end
24
+
25
+ private
26
+
27
+ # Use callbacks to share common setup or constraints between actions.
28
+ def set_profile
29
+ @profile = Profile.find(current_user)
30
+ end
31
+
32
+ # Never trust parameters from the scary internet, only allow the white list through.
33
+ def profile_params
34
+ params.require(:profile).permit( :first_name, :last_name, :other_name )
35
+ end
36
+
37
+ end
@@ -0,0 +1,2 @@
1
+ class Member < User
2
+ end
@@ -0,0 +1,3 @@
1
+ class Profile < User
2
+
3
+ end
@@ -0,0 +1,16 @@
1
+ <% if administrator? %>
2
+
3
+ <% content_for :admin_context_menu do %>
4
+
5
+ <h2><%= t('admin_section') %></h2>
6
+ <ul class="list-group">
7
+ <li class="list-group-item"><%= link_to t('admin_panel'), members_path %></li>
8
+ <%= content_tag :li, link_to( "#{t('activerecord.models.comments').capitalize} <span class='badge'>#{Comment.pending.count}</span>".html_safe, pending_comments_path ), class: 'list-group-item' if Comment.pending.count > 0 %>
9
+ <% if controller.action_name == 'show' %>
10
+ <li class="list-group-item"><%= link_to 'Modify this member record', edit_member_path(member) %></li>
11
+ <% end %>
12
+ </ul>
13
+
14
+ <% end -%>
15
+
16
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <%= simple_form_for @member do |f| %>
2
+ <%= f.error_notification %>
3
+
4
+ <%= f.input :first_name, label: t('activerecord.attributes.users.first_name') %>
5
+ <%= f.input :last_name, label: t('activerecord.attributes.users.last_name') %>
6
+ <%= f.input :other_name, label: t('activerecord.attributes.users.other_name'), hint: 'nickname, spiritual name, etc.' %>
7
+ <%= f.input :email, label: t('activerecord.attributes.users.email'), hint: 'change with caution!!!! the email is used to login.' %>
8
+
9
+ <%= f.button :submit, :class => 'btn btn-primary' %>
10
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Members</h1>
2
+ <ul class="nav nav-tabs" id="admin-menu-tab">
3
+ <%= content_tag :li, link_to(t('new'), new_member_path), ({ class: 'active' } if controller.action_name.to_s == 'new' ) %>
4
+ <%= content_tag :li, link_to(t('list'), members_path), ({ class: 'active' } if controller.action_name.to_s == 'index' ) %>
5
+ <%= content_tag :li, link_to(t('edit'), '#'), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
6
+ </ul>
@@ -0,0 +1,5 @@
1
+ <%= render 'tab_admin_menu' %>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= render 'shared/admin_sidebar' %>
@@ -0,0 +1,37 @@
1
+ <%= render 'tab_admin_menu' %>
2
+
3
+ <%= will_paginate @members, inner_window: 2 %>
4
+
5
+ <table class='table table-striped'>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Email</th>
10
+ <th>Admin?</th>
11
+ <th><%= t('actions') %></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% @members.each do |member| %>
17
+ <tr>
18
+ <td><%= link_to member.name, member, title: 'view' %></td>
19
+ <td><%= member.email %></td>
20
+ <td>
21
+ <% unless member.admin? %>
22
+ <span class="glyphicon glyphicon-remove"></span> <%= link_to t('authentication.enable_admin'), make_admin_user_path(member), class: 'btn btn-xs btn-default', method: :post %>
23
+ <% else %>
24
+ <span class="glyphicon glyphicon-ok"></span> <%= link_to t('authentication.disable_admin'), remove_admin_user_path(member), class: 'btn btn-xs btn-primary', method: :post %>
25
+ <% end -%>
26
+ </td>
27
+ <td><%= link_to t('edit'), edit_member_path(member), :class => 'btn btn-xs btn-default' %><%= link_to t('delete'), member, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-xs btn-danger' %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+
33
+ <%= will_paginate @members, inner_window: 2 %>
34
+
35
+ <p><%= link_to 'Add a New Member', new_member_path, class: 'btn btn-default' %></p>
36
+
37
+ <%= render 'shared/admin_sidebar' %>
@@ -0,0 +1,5 @@
1
+ <%= render 'tab_admin_menu' %>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= render 'shared/admin_sidebar' %>
@@ -0,0 +1,21 @@
1
+ <% content_for :meta_title, @member.name %>
2
+ <% content_for :meta_description, "Public profile for #{@member.name}" %>
3
+
4
+ <div id="profile-title">
5
+ <% if student.other_name.present? %>
6
+ <h1>
7
+ <%= student.other_name %><br />
8
+ <span class="secondary-name"><%= student.name %></span>
9
+ </h1>
10
+ <% else %>
11
+ <h1><%= student.name %></h1>
12
+ <% end %>
13
+ </div>
14
+
15
+ <table id="profile-attributes">
16
+ <tbody>
17
+ <%= render 'profiles/custom_public_profile_attributes' %>
18
+ </tbody>
19
+ </table>
20
+
21
+ <%= render 'admin_context_menu', member: @member %>
@@ -0,0 +1,15 @@
1
+ <% if administrator? %>
2
+
3
+ <% content_for :admin_context_menu do %>
4
+
5
+ <h2><%= t('admin_section') %></h2>
6
+ <ul class="list-group">
7
+ <li class="list-group-item"><%= link_to t('admin_panel'), members_path %></li>
8
+ <%= content_tag :li, link_to( "#{t('activerecord.models.comments').capitalize} <span class='badge'>#{Comment.pending.count}</span>".html_safe, pending_comments_path ), class: 'list-group-item' if Comment.pending.count > 0 %>
9
+ <% if controller.action_name == 'show' %>
10
+ <% end %>
11
+ </ul>
12
+
13
+ <% end -%>
14
+
15
+ <% end -%>
@@ -0,0 +1 @@
1
+ <% # place partial of same name in /app/views/profiles to add fields %>
@@ -0,0 +1 @@
1
+ <% # place partial of same name in /app/views/profiles to add fields %>
@@ -0,0 +1,5 @@
1
+ <ul class="nav nav-tabs" id="tab-menu">
2
+ <%= content_tag :li, link_to('<span class="glyphicon glyphicon-user"></span>&nbsp;profile'.html_safe, profile_path), ({ class: 'active' } if controller.action_name.to_s == 'show' ) %>
3
+ <%= content_tag :li, link_to("<span class=\"glyphicon glyphicon-pencil\"></span>&nbsp;#{t('edit')}".html_safe, edit_profile_path), ({ class: 'active' } if controller.action_name.to_s == 'edit' ) %>
4
+ <%= content_tag :li, link_to('history', profile_history_path), ({ class: 'active' } if controller.action_name.to_s == 'history' ) %>
5
+ </ul>
@@ -0,0 +1,18 @@
1
+ <% content_for :meta_title, 'Editing My Profile' %>
2
+ <% content_for :meta_description, "This is where the site's user can edit his or her profile information" %>
3
+
4
+ <%= render 'tab_menu' %>
5
+
6
+ <%= simple_form_for @profile, url: profile_path do |f| %>
7
+ <%= f.error_notification %>
8
+
9
+ <p>Email: <strong><%= @profile.email %></strong>. Unfortunately, you cannot yet change your email address. This feature is coming soon.</p>
10
+
11
+ <%= f.input :first_name, label: t('activerecord.attributes.users.first_name') %>
12
+ <%= f.input :last_name, label: t('activerecord.attributes.users.last_name') %>
13
+ <%= f.input :other_name, label: render( 'shared/other_name_label') %>
14
+
15
+ <%= f.button :submit, :class => 'btn btn-primary' %>
16
+ <% end %>
17
+
18
+ <%= render'admin_context_menu' %>
@@ -0,0 +1,41 @@
1
+ <% content_for :meta_title, 'My Profile History' %>
2
+ <% content_for :meta_description, "List of a user's historical activities on the site." %>
3
+
4
+ <%= render 'tab_menu' %>
5
+
6
+ <div id="profile-title">
7
+ <% if @profile.other_name.present? %>
8
+ <h1>
9
+ <%= @profile.other_name %><br />
10
+ <span class="secondary-name"><%= @profile.name %></span>
11
+ </h1>
12
+ <% else %>
13
+ <h1><%= @profile.name %></h1>
14
+ <% end %>
15
+ </div>
16
+
17
+ <br />
18
+
19
+ <table class='table table-striped'>
20
+ <thead>
21
+ <tr>
22
+ <th>When?</th>
23
+ <th>What happened?</th>
24
+ </tr>
25
+ </thead>
26
+
27
+ <tbody>
28
+ <% if @activities.any? %>
29
+ <% @activities.each do |activity| %>
30
+ <tr>
31
+ <td><%= human_date_and_time(activity.created_at) %></td>
32
+ <td><%= "You #{activity.message}".html_safe %></td>
33
+ </tr>
34
+ <% end %>
35
+ <% else # no activities %>
36
+ <tr><td>You don't have any activities yet.</td></tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+
41
+ <%= render 'admin_context_menu' %>
@@ -0,0 +1,32 @@
1
+ <% content_for :meta_title, 'My Profile' %>
2
+ <% content_for :meta_description, "My profile administration section for the logged in user" %>
3
+
4
+ <%= render 'tab_menu' %>
5
+
6
+ <div id="profile-title">
7
+ <% if @profile.other_name.present? %>
8
+ <h1>
9
+ <%= @profile.other_name %><br />
10
+ <span class="secondary-name"><%= @profile.name %></span>
11
+ </h1>
12
+ <% else %>
13
+ <h1><%= @profile.name %></h1>
14
+ <% end %>
15
+ </div>
16
+
17
+ <table id="profile-attributes">
18
+ <tbody>
19
+ <tr><td class="section" colspan="2"><span class="label label-danger">private information</span></td></tr>
20
+ <tr><td class="key"><span class="glyphicon glyphicon-envelope"></span> email address</td><td class="value"><%= @profile.email %></td></tr>
21
+ <%= render 'custom_private_profile_attributes' %>
22
+ <tr><td class="section" colspan="2"><span class="label label-success">public information</span></td></tr>
23
+ <tr><td class="key">first name</td><td class="value"><%= @profile.first_name %></td></tr>
24
+ <tr><td class="key">last name</td><td class="value"><%= @profile.last_name %></td></tr>
25
+ <tr><td class="key"><%= render 'shared/other_name_label' %></td><td class="value"><%= @profile.other_name %></td></tr>
26
+ <%= render 'custom_public_profile_attributes' %>
27
+ </tbody>
28
+ </table>
29
+
30
+ <p class="text-center"><%= link_to "<span class=\"glyphicon glyphicon-pencil\"></span> change your info".html_safe, edit_profile_path, class: 'btn btn-sm btn-default' %></p>
31
+
32
+ <%= render'admin_context_menu' %>
@@ -1,5 +1,14 @@
1
1
  Rails.application.routes.draw do
2
2
  scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
3
- resources :details
3
+
4
+ # Mailing list records for admin
5
+ resources :details # deprecated. Should disappear soon.
6
+
7
+ # for public viewing and admin editing
8
+ resources :members
9
+ # for user to edit and view privately
10
+ resource :profile, only: [ :show, :edit, :update ]
11
+ get 'profile_history' => 'profiles#history'
12
+
4
13
  end
5
14
  end
@@ -10,3 +10,14 @@ de:
10
10
  destroy:
11
11
  notice: 'This user has been deleted.'
12
12
  warning: 'A problem occurred while deleting this user.'
13
+
14
+ members:
15
+ create:
16
+ notice: 'This user has been created.'
17
+ warning: 'A problem occurred while creating this user.'
18
+ update:
19
+ notice: 'This user has been updated.'
20
+ warning: "A problem occurred while updating this user's record."
21
+ destroy:
22
+ notice: 'This user has been deleted.'
23
+ warning: 'A problem occurred while deleting this user.'
@@ -10,3 +10,15 @@ en:
10
10
  destroy:
11
11
  notice: 'This user has been deleted.'
12
12
  warning: 'A problem occurred while deleting this user.'
13
+
14
+
15
+ members:
16
+ create:
17
+ notice: 'This user has been created.'
18
+ warning: 'A problem occurred while creating this user.'
19
+ update:
20
+ notice: 'This user has been updated.'
21
+ warning: "A problem occurred while updating this user's record."
22
+ destroy:
23
+ notice: 'This user has been deleted.'
24
+ warning: 'A problem occurred while deleting this user.'
@@ -10,3 +10,14 @@ es:
10
10
  destroy:
11
11
  notice: 'This user has been deleted.'
12
12
  warning: 'A problem occurred while deleting this user.'
13
+
14
+ members:
15
+ create:
16
+ notice: 'This user has been created.'
17
+ warning: 'A problem occurred while creating this user.'
18
+ update:
19
+ notice: 'This user has been updated.'
20
+ warning: "A problem occurred while updating this user's record."
21
+ destroy:
22
+ notice: 'This user has been deleted.'
23
+ warning: 'A problem occurred while deleting this user.'
@@ -10,3 +10,14 @@ fr:
10
10
  destroy:
11
11
  notice: "Cet utilisateur n'est plus dans la base de données."
12
12
  warning: "Il y a eu un problème qui n'a pas permis d'éléliminer cet utilisateur"
13
+
14
+ members:
15
+ create:
16
+ notice: 'Un nouvel utilisateur a été ajouté à la base de données.'
17
+ warning: "Il y a eu un problème qui n'a pas permis d'ajouter cet utilisateur"
18
+ update:
19
+ notice: 'Les données de cet utilisateur ont été modifiées'
20
+ warning: "Il y a eu un problème qui n'a pas permis de modifier les données de cet utilisateur"
21
+ destroy:
22
+ notice: "Cet utilisateur n'est plus dans la base de données."
23
+ warning: "Il y a eu un problème qui n'a pas permis d'éléliminer cet utilisateur"
@@ -1,3 +1,3 @@
1
1
  module TkhMailingList
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10"
3
3
  end
@@ -20,6 +20,4 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
-
24
- spec.add_dependency "tkh_authentication", '~> 0.9.2'
25
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_mailing_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swami Atma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: tkh_authentication
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.9.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.9.2
55
41
  description: A mailing list module to work with tkh_authentication gem
56
42
  email:
57
43
  - swami@TenThousandHours.eu
@@ -67,12 +53,30 @@ files:
67
53
  - README.md
68
54
  - Rakefile
69
55
  - app/controllers/details_controller.rb
56
+ - app/controllers/members_controller.rb
57
+ - app/controllers/profiles_controller.rb
70
58
  - app/models/detail.rb
59
+ - app/models/member.rb
60
+ - app/models/profile.rb
71
61
  - app/views/details/_form.html.erb
72
62
  - app/views/details/_tab_admin_menu.html.erb
73
63
  - app/views/details/edit.html.erb
74
64
  - app/views/details/new.html.erb
75
65
  - app/views/details/show.html.erb
66
+ - app/views/members/_admin_context_menu.html.erb
67
+ - app/views/members/_form.html.erb
68
+ - app/views/members/_tab_admin_menu.html.erb
69
+ - app/views/members/edit.html.erb
70
+ - app/views/members/index.html.erb
71
+ - app/views/members/new.html.erb
72
+ - app/views/members/show.html.erb
73
+ - app/views/profiles/_admin_context_menu.html.erb
74
+ - app/views/profiles/_custom_private_profile_attributes.html.erb
75
+ - app/views/profiles/_custom_public_profile_attributes.html.erb
76
+ - app/views/profiles/_tab_menu.html.erb
77
+ - app/views/profiles/edit.html.erb
78
+ - app/views/profiles/history.html.erb
79
+ - app/views/profiles/show.html.erb
76
80
  - config/routes.rb
77
81
  - lib/generators/tkh_mailing_list/create_or_update_locales/create_or_update_locales_generator.rb
78
82
  - lib/generators/tkh_mailing_list/create_or_update_locales/templates/de.yml