Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1244114c

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

  • ID 1244114ce9ffb1eccfb73b73c78c5f78424824bd
  • Vorgänger 1d13e16e
  • Nachfolger f059f224

Gültigkeitstoken Lieferscheincontroller

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
30 30
use SL::DB::Shipto;
31 31
use SL::DB::Translation;
32 32
use SL::DB::TransferType;
33
use SL::DB::ValidityToken;
33 34
use SL::DB::Warehouse;
34 35

  
35 36
use SL::Helper::CreatePDF qw(:all);
......
81 82

  
82 83

  
83 84
  $self->pre_render();
85

  
86
  if (!$::form->{form_validity_token}) {
87
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE())->token;
88
  }
89

  
84 90
  $self->render(
85 91
    'delivery_order/form',
86 92
    title => $self->get_title_for('add'),
......
131 137
    # are loaded only on demand. So we need to keep the values from
132 138
    # the source.
133 139
    $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
140

  
141
    if (!$::form->{form_validity_token}) {
142
      $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE())->token;
143
    }
134 144
  }
135 145

  
136 146
  $self->pre_render();
......
252 262
  # no linked records on save as new
253 263
  delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
254 264

  
265
  if (!$::form->{form_validity_token}) {
266
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE())->token;
267
  }
268

  
255 269
  # save
256 270
  $self->action_save();
257 271
}
......
1644 1658
sub save {
1645 1659
  my ($self) = @_;
1646 1660

  
1661
  my $validity_token;
1662
  if (!$self->order->id) {
1663
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
1664
      scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE(),
1665
      token => $::form->{form_validity_token},
1666
    );
1667

  
1668
    return [t8('The form is not valid anymore.')] if !$validity_token;
1669
  }
1670

  
1647 1671
  my $errors = [];
1648 1672
  my $db     = $self->order->db;
1649 1673

  
......
1705 1729

  
1706 1730
    $self->save_history('SAVED');
1707 1731

  
1732
    $validity_token->delete if $validity_token;
1733
    delete $::form->{form_validity_token};
1734

  
1708 1735
    1;
1709 1736
  }) || push(@{$errors}, $db->error);
1710 1737

  
templates/webpages/delivery_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">

Auch abrufbar als: Unified diff