Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
CI / scan_ruby (push) Failing after 11m20s
CI / scan_js (push) Successful in 10m35s
CI / lint (push) Has been cancelled

Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 23:01:48 +02:00
co-authored by Cursor
commit c4e5f289cf
258 changed files with 11293 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
class ActivitiesController < ApplicationController
before_action :set_organization, only: %i[create]
def create
@activity = @organization.activities.build(activity_params)
@activity.user = current_user
@activity.happened_at ||= Time.current
if @activity.save
maybe_update_pipeline_from_activity!
redirect_to @organization, notice: "Attività registrata."
else
redirect_to @organization, alert: @activity.errors.full_messages.to_sentence
end
end
private
def set_organization
@organization = Organization.find(params[:organization_id])
end
def activity_params
params.require(:activity).permit(
:activity_type, :subject, :description, :happened_at, :contact_id, :opportunity_id
)
end
def maybe_update_pipeline_from_activity!
opportunity = @activity.opportunity || @organization.opportunities.open_stage.order(updated_at: :desc).first
return unless opportunity
stage_map = {
"email_sent" => "contacted",
"email_received" => "replied",
"call" => "contacted",
"demo" => "demo_trial",
"trial_started" => "demo_trial",
"first_use" => "first_use",
"proposal_sent" => "proposal",
"won" => "won",
"lost" => "lost"
}
target = stage_map[@activity.activity_type]
return unless target
return if opportunity.won? || opportunity.lost?
return if Catalog::PIPELINE_ORDER.index(opportunity.pipeline_stage).to_i >= Catalog::PIPELINE_ORDER.index(target).to_i
attrs = { pipeline_stage: target }
if target == "lost"
attrs[:lost_reason] = params[:lost_reason].presence || "other"
end
opportunity.move_to_stage!(target, lost_reason: attrs[:lost_reason], user: current_user)
end
end