bullet_train 1.4.6 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07a965daba64c07c54a925adad5ca51fcfd30496790e350d2846de6c864fda65
4
- data.tar.gz: 4c0fbeabceb820a417340e8d27a588ece5482622db32016b74b504989bbbb7b1
3
+ metadata.gz: 86b25cd3f8b935ed66013d2f4f906a58f50445a1d0250fc92f661d96478c9798
4
+ data.tar.gz: 2020c0ee2cc8d7e14f96f4ff00976729227b434d0c94ba216e8eeeb2ab93c6df
5
5
  SHA512:
6
- metadata.gz: da6e96885f39b697c2bb1e6b4a80fbd3532ca174b2b807d8b17d31882764b26131fa03457d31b4dd02471ceaa4724f12b841fb752ae3eecbcc809cccff5b8c10
7
- data.tar.gz: 638389f69f535a1bfd49fe4ded96026dc83b7f444d449b1e69be9a8b78b9ea0f633a9b4020d0734424d56a8c93e01af70bcf4ae4894d5fa423475b235621bb71
6
+ metadata.gz: 75b39744eeffb426ad00c56dc257ab48f3039914f4372093ea49b2a50ec7ec64fac89876f5e0e4856fb179273ba7949f472699147d9a9d8cc01ae0c101304b1c
7
+ data.tar.gz: 1f4ed96750b8261f799f7aff62e64356360319039a71292f18ac51e004de902e8d40cea5dea28c6ce1bc6a3d8dd345564841132bf3a19e6322fa918ee0f7a517
@@ -110,13 +110,17 @@ module Account::Teams::ControllerBase
110
110
 
111
111
  # # DELETE /teams/1
112
112
  # # DELETE /teams/1.json
113
- # def destroy
114
- # @team.destroy
115
- # respond_to do |format|
116
- # format.html { redirect_to account_teams_url, notice: 'Team was successfully destroyed.' }
117
- # format.json { head :no_content }
118
- # end
119
- # end
113
+ def destroy
114
+ respond_to do |format|
115
+ raise RemovingLastTeamException if current_user.one_team?
116
+ @team.destroy
117
+ format.html { redirect_to account_teams_url, notice: t("account.teams.notifications.destroyed") }
118
+ format.json { head :no_content }
119
+ rescue RemovingLastTeamException => _
120
+ format.html { redirect_to edit_account_team_url(@team), alert: t("account.teams.notifications.cannot_delete_last_team") }
121
+ format.json { head :no_content }
122
+ end
123
+ end
120
124
 
121
125
  private
122
126
 
@@ -7,6 +7,10 @@ module Teams::Base
7
7
  has_many :scaffolding_absolutely_abstract_creative_concepts, class_name: "Scaffolding::AbsolutelyAbstract::CreativeConcept", dependent: :destroy, enable_cable_ready_updates: true
8
8
  end
9
9
 
10
+ # added_by_id is a foreign_key to other Memberships on the same team,
11
+ # so we nullify this to remove the constraint to delete the team.
12
+ before_destroy { Membership.where(team: self).update_all(added_by_id: nil) }
13
+
10
14
  # memberships and invitations
11
15
  has_many :memberships, dependent: :destroy
12
16
  has_many :users, through: :memberships
@@ -17,6 +17,9 @@
17
17
 
18
18
  <div class="buttons">
19
19
  <%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
20
+ <% if controller.action_name == "edit" %>
21
+ <%= link_to t('account.teams.buttons.destroy'), [:account, team], method: :delete, data: { confirm: t('account.teams.buttons.confirmations.destroy') } %>
22
+ <% end %>
20
23
  <%= link_to t('global.buttons.cancel'), form.object.persisted? ? [:account, team] : [:account, :teams], class: "button-secondary" %>
21
24
  </div>
22
25
  <% end %>
@@ -13,6 +13,9 @@ en:
13
13
  create: Create Team
14
14
  edit: Edit Team
15
15
  update: Update Team
16
+ destroy: Delete Team
17
+ confirmations:
18
+ destroy: Are you sure you want to delete this team?
16
19
  index:
17
20
  section: Teams
18
21
  header: Your Teams
@@ -40,7 +43,9 @@ en:
40
43
  notifications:
41
44
  created: Team was successfully created.
42
45
  updated: Team was successfully updated.
46
+ destroyed: Team was successfully destroyed.
43
47
  invitation_only: Creating new teams is currently limited to users who have been invited for early access. If you've received an early access URL, please visit it before trying again.
48
+ cannot_delete_last_team: You cannot delete the last team you belong to.
44
49
  form:
45
50
  buttons: *buttons
46
51
  fields: &fields
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.4.6"
2
+ VERSION = "1.4.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard