mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-08-26 21:52:40 +00:00
postkey/views.py: add docstrings
This commit is contained in:
parent
dd97e57f0f
commit
85981abf58
@ -8,6 +8,10 @@ from web.postkey.models import i2phost
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
class AddForm(ModelForm):
|
class AddForm(ModelForm):
|
||||||
|
"""
|
||||||
|
This is our class for host-add form. It's based on django's ModelForm
|
||||||
|
and uses our model "i2phost" (see postkey/models.py)
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = i2phost
|
model = i2phost
|
||||||
fields = ('name', 'b64hash', 'description')
|
fields = ('name', 'b64hash', 'description')
|
||||||
@ -17,6 +21,10 @@ class AddForm(ModelForm):
|
|||||||
'description': forms.Textarea(attrs={'rows': '2', 'cols': '72'})
|
'description': forms.Textarea(attrs={'rows': '2', 'cols': '72'})
|
||||||
}
|
}
|
||||||
def clean_name(self):
|
def clean_name(self):
|
||||||
|
"""
|
||||||
|
Here we do additional hostname validation as described in
|
||||||
|
http://www.i2p2.i2p/naming.html
|
||||||
|
"""
|
||||||
data = self.cleaned_data['name']
|
data = self.cleaned_data['name']
|
||||||
# convert hostname to lowercase
|
# convert hostname to lowercase
|
||||||
data = data.lower()
|
data = data.lower()
|
||||||
@ -46,6 +54,9 @@ class AddForm(ModelForm):
|
|||||||
raise forms.ValidationError('Trying to use reserved hostname')
|
raise forms.ValidationError('Trying to use reserved hostname')
|
||||||
return data
|
return data
|
||||||
def clean_b64hash(self):
|
def clean_b64hash(self):
|
||||||
|
"""
|
||||||
|
Base64 hash validation
|
||||||
|
"""
|
||||||
data = self.cleaned_data['b64hash']
|
data = self.cleaned_data['b64hash']
|
||||||
# Minimum key length 516 bytes
|
# Minimum key length 516 bytes
|
||||||
if len(data) < 516:
|
if len(data) < 516:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user