# Copyright 2021 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

""" Copyright 2012, 2013 UW Information Technology, University of Washington

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is 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.

"""

from django import forms
from spotseeker_server.models import Item, ItemExtendedInfo
import re


class DefaultItemExtendedInfoForm(forms.ModelForm):

    class Meta:
        model = ItemExtendedInfo
        fields = '__all__'

    def clean_key(self):
        key = self.cleaned_data['key'].strip()
        if not re.match(r'^[a-z0-9_-]+$', key, re.I):
            raise forms.ValidationError(
                "Key must be only alphanumerics, underscores, and hyphens")
        return key


class DefaultItemForm(forms.ModelForm):

    class Meta:
        model = Item
        fields = ('name', 'item_category', 'item_subcategory')

@@ -85,648 +85,8 @@
 .0%0A%0A
-%22%22%22 Copyright 2012, 2013 UW Information Technology, University of Washington%0A%0A    Licensed under the Apache License, Version 2.0 (the %22License%22);%0A    you may not use this file except in compliance with the License.%0A    You may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0A    Unless required by applicable law or agreed to in writing, software%0A    distributed under the License is distributed on an %22AS IS%22 BASIS,%0A    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A    See the License for the specific language governing permissions and%0A    limitations under the License.%0A%0A%22%22%22%0A%0A
 from
@@ -222,33 +222,32 @@
 rms.ModelForm):%0A
-%0A
     class Meta:%0A
@@ -300,17 +300,17 @@
 s = 
-'
+%22
 __all__
-'
+%22
 %0A%0A  
@@ -368,13 +368,13 @@
 ata%5B
-'key'
+%22key%22
 %5D.st
@@ -404,17 +404,17 @@
 .match(r
-'
+%22
 %5E%5Ba-z0-9
@@ -418,17 +418,17 @@
 0-9_-%5D+$
-'
+%22
 , key, r
@@ -548,16 +548,29 @@
 hyphens%22
+%0A            
 )%0A      
@@ -624,17 +624,16 @@
 lForm):%0A
-%0A
     clas
@@ -683,17 +683,17 @@
  = (
-'
+%22
 name
-', '
+%22, %22
 item
@@ -705,12 +705,12 @@
 gory
-', '
+%22, %22
 item
@@ -725,7 +725,7 @@
 gory
-'
+%22
 )%0A

Reformat and update copyright.