forked from CGM_Public/pretix_original
Item copy: Copy picture
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is
|
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is
|
||||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations under the License.
|
# License for the specific language governing permissions and limitations under the License.
|
||||||
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
@@ -346,6 +346,7 @@ class ItemCreateForm(I18nModelForm):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.cleaned_data.get('copy_from'):
|
if self.cleaned_data.get('copy_from'):
|
||||||
|
src = self.cleaned_data['copy_from']
|
||||||
fields = (
|
fields = (
|
||||||
'description',
|
'description',
|
||||||
'active',
|
'active',
|
||||||
@@ -375,7 +376,10 @@ class ItemCreateForm(I18nModelForm):
|
|||||||
'grant_membership_duration_months',
|
'grant_membership_duration_months',
|
||||||
)
|
)
|
||||||
for f in fields:
|
for f in fields:
|
||||||
setattr(self.instance, f, getattr(self.cleaned_data['copy_from'], f))
|
setattr(self.instance, f, getattr(src, f))
|
||||||
|
|
||||||
|
if src.picture:
|
||||||
|
self.instance.picture.save(os.path.basename(src.picture.name), src.picture)
|
||||||
else:
|
else:
|
||||||
# Add to all sales channels by default
|
# Add to all sales channels by default
|
||||||
self.instance.sales_channels = list(get_all_sales_channels().keys())
|
self.instance.sales_channels = list(get_all_sales_channels().keys())
|
||||||
|
|||||||
Reference in New Issue
Block a user