Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5cada5ab

Von Bernd Bleßmann vor fast 2 Jahren hinzugefügt

  • ID 5cada5ab5524d4eccbfe2beacb8c5b46314f1368
  • Vorgänger a03e4841
  • Nachfolger 13193b1a

Gültigkeitstoken Auftragscontroller

Unterschiede anzeigen:

SL/Controller/Order.pm
31 31
use SL::DB::RequirementSpec;
32 32
use SL::DB::Shipto;
33 33
use SL::DB::Translation;
34
use SL::DB::ValidityToken;
34 35

  
35 36
use SL::Helper::CreatePDF qw(:all);
36 37
use SL::Helper::PrintOptions;
......
86 87

  
87 88

  
88 89
  $self->pre_render();
90

  
91
  if (!$::form->{form_validity_token}) {
92
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token;
93
  }
94

  
89 95
  $self->render(
90 96
    'order/form',
91 97
    title => $self->get_title_for('add'),
......
107 113

  
108 114
  $self->recalc();
109 115
  $self->pre_render();
116

  
117
  if (!$::form->{form_validity_token}) {
118
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token;
119
  }
120

  
110 121
  $self->render(
111 122
    'order/form',
112 123
    title => $self->get_title_for('edit'),
......
132 143
    # are loaded only on demand. So we need to keep the values from
133 144
    # the source.
134 145
    $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
146

  
147
    if (!$::form->{form_validity_token}) {
148
      $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token;
149
    }
135 150
  }
136 151

  
137 152
  $self->recalc();
......
306 321
  # no linked records on save as new
307 322
  delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
308 323

  
324
  if (!$::form->{form_validity_token}) {
325
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token;
326
  }
327

  
309 328
  # save
310 329
  $self->action_save();
311 330
}
......
943 962
  # source.
944 963
  $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
945 964

  
965
  if (!$::form->{form_validity_token}) {
966
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token;
967
  }
968

  
946 969
  $self->render(
947 970
    'order/form',
948 971
    title => $self->get_title_for('edit'),
......
2097 2120
sub save {
2098 2121
  my ($self) = @_;
2099 2122

  
2123
  my $validity_token;
2124
  if (!$self->order->id) {
2125
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
2126
      scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE(),
2127
      token => $::form->{form_validity_token},
2128
    );
2129

  
2130
    return [t8('The form is not valid anymore.')] if !$validity_token;
2131
  }
2132

  
2100 2133
  $self->recalc();
2101 2134
  $self->get_unalterable_data();
2102 2135

  
......
2189 2222

  
2190 2223
    $self->save_history('SAVED');
2191 2224

  
2225
    $validity_token->delete if $validity_token;
2226
    delete $::form->{form_validity_token};
2227

  
2192 2228
    1;
2193 2229
  }) || push(@{$errors}, $db->error);
2194 2230

  
SL/DB/ValidityToken.pm
13 13

  
14 14
use constant SCOPE_SALES_INVOICE_POST  => 'SalesInvoice::Post';
15 15
use constant SCOPE_DELIVERY_ORDER_SAVE => 'DeliveryOrder::Save';
16
use constant SCOPE_ORDER_SAVE          => 'Order::Save';
16 17

  
17 18
sub create {
18 19
  my ($class, %params) = @_;
templates/design40_webpages/order/form.html
22 22
  [% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
23 23
  [% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
24 24

  
25
  [% IF !SELF.order.id %]
26
  [%   L.hidden_tag('form_validity_token', FORM.form_validity_token) %]
27
  [% END %]
28

  
25 29
  [% INCLUDE 'common/flash.html' %]
26 30

  
27 31
<div class="tabwidget" id="order_tabs">
templates/webpages/order/form.html
24 24
  [% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
25 25
  [% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
26 26

  
27
  [% IF !SELF.order.id %]
28
  [%   L.hidden_tag('form_validity_token', FORM.form_validity_token) %]
29
  [% END %]
30

  
27 31
  [%- INCLUDE 'common/flash.html' %]
28 32

  
29 33
  <div class="tabwidget" id="order_tabs">

Auch abrufbar als: Unified diff