<commit_before>from django import forms
from django.utils.translation import ugettext as _
from django.contrib.auth.models import User
from wlanlj.generator.models import Template, Profile
from wlanlj.nodes import ipcalc
from datetime import datetime
import re

IPV4_ADDR_RE = re.compile(r'\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b')

class GenerateImageForm(forms.Form):
  """
  A simple form for image generation.
  """
  config_only = forms.BooleanField(initial = False, required = False, label = _("Configuration only"))
  email_user = forms.ModelChoiceField(
    User.objects.filter(is_active = True),
    initial = User.objects.filter(is_active = True)[0].id,
    required = False,
    label = _("Send image to")
  )

  def clean(self):
    """
    Additional validation handler.
    """
    email_user = self.cleaned_data.get('email_user')

    if email_user and not email_user.email:
      raise forms.ValidationError(_("Specified user does not have an e-mail configured!"))

    return self.cleaned_data
  
  def save(self, node):
    """
    Saves modifiable stuff into the profile
    """
    return node.owner if not self.cleaned_data.get('email_user') else self.cleaned_data.get('email_user')
<commit_msg>Users should be sorted by their username.<commit_after>from django import forms
from django.utils.translation import ugettext as _
from django.contrib.auth.models import User
from wlanlj.generator.models import Template, Profile
from wlanlj.nodes import ipcalc
from datetime import datetime
import re

IPV4_ADDR_RE = re.compile(r'\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b')

class GenerateImageForm(forms.Form):
  """
  A simple form for image generation.
  """
  config_only = forms.BooleanField(initial = False, required = False, label = _("Configuration only"))
  email_user = forms.ModelChoiceField(
    User.objects.filter(is_active = True).order_by("username"),
    initial = User.objects.filter(is_active = True)[0].id,
    required = False,
    label = _("Send image to")
  )

  def clean(self):
    """
    Additional validation handler.
    """
    email_user = self.cleaned_data.get('email_user')

    if email_user and not email_user.email:
      raise forms.ValidationError(_("Specified user does not have an e-mail configured!"))

    return self.cleaned_data
  
  def save(self, node):
    """
    Saves modifiable stuff into the profile
    """
    return node.owner if not self.cleaned_data.get('email_user') else self.cleaned_data.get('email_user')

{'fraction_non_alphanumeric': 0.1421398223252221, 'fraction_numerical': 0.02549246813441483, 'mean_word_length': 4.128712871287129, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208177', 'n_tokens_mistral': 871, 'n_tokens_neox': 856, 'n_words': 202}