mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Allow to set the initial lexer via GET.
This commit is contained in:
parent
1fce9e38f6
commit
691c21dd0f
1 changed files with 6 additions and 1 deletions
|
@ -59,6 +59,11 @@ class SnippetForm(forms.ModelForm):
|
|||
if session_lexer and session_lexer in dict(LEXER_LIST).keys():
|
||||
self.fields['lexer'].initial = session_lexer
|
||||
|
||||
# if the lexer is given via GET, set it
|
||||
if 'l' in request.GET and request.GET['l'] in dict(LEXER_LIST).keys():
|
||||
self.fields['lexer'].initial = request.GET['l']
|
||||
|
||||
|
||||
def clean_content(self):
|
||||
return self.cleaned_data.get('content', '').strip()
|
||||
|
||||
|
@ -92,4 +97,4 @@ class SnippetForm(forms.ModelForm):
|
|||
# Save the lexer in the session so we can use it later again
|
||||
self.request.session['lexer'] = self.cleaned_data['lexer']
|
||||
|
||||
return self.instance
|
||||
return self.instance
|
||||
|
|
Loading…
Reference in a new issue