Skip to content

Commit

Permalink
Merge e98de4c into 51ccad5
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp committed Nov 8, 2022
2 parents 51ccad5 + e98de4c commit 602bcab
Show file tree
Hide file tree
Showing 59 changed files with 1,238 additions and 20,385 deletions.
10 changes: 1 addition & 9 deletions app/controllers/reimbursements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ def create
end
end

def show
# We don't want to break the normal process if something goes wrong
begin
resource.user.profile.refresh
rescue
nil
end
show!
end
def show; end

def check_request
@reimbursement = Reimbursement.where(request_id: params[:request_id]).includes(user: :profile).first
Expand Down
10 changes: 1 addition & 9 deletions app/controllers/shipments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ class ShipmentsController < InheritedResources::Base
skip_load_resource only: [:index, :new]
before_filter :set_states_collection, only: [:index]

def show
# We don't want to break the normal process if something goes wrong
begin
resource.user.profile.refresh
rescue
nil
end
show!
end
def show; end

def create
@shipment ||= Shipment.new(params[:shipment])
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/travel_sponsorships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ def new
end

def show
# We don't want to break the normal process if something goes wrong
begin
resource.user.profile.refresh
rescue
nil
end
@request = resource
show!
end

protected
Expand Down
1 change: 0 additions & 1 deletion app/controllers/user_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def update_password
def set_user_and_profile
@user = current_user
@profile = @user.find_profile
@profile.refresh
end

def users_controller?
Expand Down
33 changes: 0 additions & 33 deletions app/helpers/user_profiles_helper.rb

This file was deleted.

42 changes: 0 additions & 42 deletions app/models/connect_user.rb

This file was deleted.

21 changes: 0 additions & 21 deletions app/models/elgg.rb

This file was deleted.

62 changes: 0 additions & 62 deletions app/models/user_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class UserProfile < ActiveRecord::Base
belongs_to_active_hash :role, class_name: 'UserRole', shortcuts: [:name]

after_initialize :set_default_attrs, if: :new_record?
before_validation do
self.attributes = connect_attrib_values
end

delegate :name, to: :role, prefix: true, allow_nil: true

Expand All @@ -33,42 +30,6 @@ class UserProfile < ActiveRecord::Base

def set_default_attrs
self.role_name ||= 'none'
self.attributes = connect_attrib_values
end

# Attributed that are fetched from openSUSE Connect
FROM_OPENSUSE_CONNECT = {
country_code: proc { |c| c.country.split(':').last.upcase },
full_name: :name,
location: :location,
birthday: proc { |c| Date.parse(c.birthday) },
phone_number: :mobile,
second_phone_number: :phone,
website: :website,
blog: :blog,
description: :briefdescription
}.freeze

# Fetchs fresh information from an external source (only openSUSE Connect at
# this moment) and updates the database.
#
# @return [Boolean] true if the information is correctly updated
def refresh
if Rails.configuration.site['opensuse_connect']['enabled']
update_attributes(connect_attrib_values)
else
true
end
end

# Checks if a given attribute is editable.
#
# @param [#to_sym] attrib attribute name
# @return [Boolean] true unless the attributes is mean to be fetched from an
# external source (openSUSE Connect at this moment)
def have_editable?(attrib)
return true unless Rails.configuration.site['opensuse_connect']['enabled']
!UserProfile::FROM_OPENSUSE_CONNECT.keys.include?(attrib.to_sym)
end

# List of fields that are required for processing reimbursements but are
Expand All @@ -82,27 +43,4 @@ def missing_fields
fields = fields.select { |f| send(f.to_sym).blank? }
Hash[fields.map { |f| [f, self.class.human_attribute_name(f)] }]
end

protected

def connect_attrib_values
return {} unless Rails.configuration.site['opensuse_connect']['enabled']
new_values = {}
connect = ConnectUser.new(user.nickname)
UserProfile::FROM_OPENSUSE_CONNECT.each_pair do |k, v|
begin
new_values[k] = if v.is_a? Symbol
connect.send(v)
elsif v.is_a? Proc
v.call(connect)
else
v
end
rescue
# Do nothing, just keep the current attribute value
true
end
end
new_values
end
end
6 changes: 0 additions & 6 deletions app/views/pages/userguide.en.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
corresponding option in the main menu or in their own username at the
top right corner of the page, next to the &#39;log out&#39; link.

- if enabled? 'opensuse_connect'
Some of the information in the profile cannot be entered directly in the
application. That information is read from
= link_to "openSUSE Connect", Rails.configuration.site['opensuse_connect']['base_url']
and should be updated in the Connect profile of the user.

- if enabled? 'travel_sponsorships'
- if enabled? 'shipments'
%h2 Applying for travel sponsorship or requesting materials
Expand Down
27 changes: 13 additions & 14 deletions app/views/user_profiles/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
= content_for :page_header do
%h1= current_user.nickname
= render 'profile_menu'
= profile_info
%br
= simple_form_for @profile, :url => user_profile_path, :as => :user do |f|
.row
.col-md-6
.col-md-4
= profile_input f, :full_name
= profile_input f, :birthday, :as => :dpicker, :input_html => {class: 'form-control'}
= profile_input f, :country_code, :as => :country, :input_html => {:autocomplete => "off"}
= profile_input f, :location
= profile_input f, :postal_address
= profile_input f, :zip_code
= profile_input f, :description, :as => :text, :input_html => {:rows => 2}
= f.input :full_name
= f.input :birthday, :as => :dpicker, :input_html => {class: 'form-control'}
= f.input :country_code, :as => :country, :input_html => {:autocomplete => "off"}
= f.input :location
= f.input :postal_address
= f.input :zip_code
= f.input :description, :as => :text, :input_html => {:rows => 2}
.col-md-6
.col-md-4
= profile_input f, :phone_number, :as => :string
= profile_input f, :second_phone_number, :as => :string
= profile_input f, :passport
= profile_input f, :alternate_id_document
= profile_input f, :website, :as => :url
= profile_input f, :blog, :as => :url
= f.input :phone_number, :as => :string
= f.input :second_phone_number, :as => :string
= f.input :passport
= f.input :alternate_id_document
= f.input :website, :as => :url
= f.input :blog, :as => :url
.row
.col-md-12
.well
Expand Down
1 change: 0 additions & 1 deletion config/locales/application.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ en:
no_reimbursement_yet: "The reimbursement process has not started"
no_history_yet: "No state changes or comments yet."
not_accepting_reimbursements: "The event is not open for requesting reimbursement"
opensuse_profile_info: 'Information on disabled controls have to be changed in <a href="%{url}">your Connect profile</a>.'
page_total: "Total in this page"
pdf_format: "Download printable version"
private_comment_label: "(Private)"
Expand Down
8 changes: 0 additions & 8 deletions config/site.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ common: &common
database:
enabled: true

opensuse_connect:
enabled: false
api_key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
base_url: "https://connect.opensuse.org"

external_links:
- title: "openSUSE TSP"
url: "http://opensuse.org/openSUSE:Travel_Support_Program"
Expand Down Expand Up @@ -84,9 +79,6 @@ test:
database:
enabled: true

opensuse_connect:
enabled: false

check_request_template: "check_request.example.pdf"
check_request_layout: "check_request.example.yml"

Expand Down

0 comments on commit 602bcab

Please sign in to comment.