<commit_before>from allauth.socialaccount.providers.base import Provider
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.utils import generate_unique_username
from django.urls import reverse
from django.utils.http import urlencode


class ServiceKontoAccount(ProviderAccount):
    def to_str(self):
        return '%s %s (%s)' % (self.account.extra_data['firstname'],
                               self.account.extra_data['lastname'],
                               self.account.extra_data['email'])


class ServiceKontoProvider(Provider):
    id = 'servicekonto'
    name = 'Service-Konto'
    account_class = ServiceKontoAccount

    def get_login_url(self, request, **kwargs):
        url = reverse(self.id + "_login")
        if kwargs:
            url = url + '?' + urlencode(kwargs)
        return url

    def extract_uid(self, data):
        return data['userid']

    def extract_common_fields(self, data):
        return {
            'username': ServiceKontoProvider._generate_username(data),
            'first_name': data['firstname'],
            'last_name': data['lastname'],
            'email': data['email'],
        }

    @staticmethod
    def _generate_username(data):
        basename = data['firstname'] + ' ' + data['lastname']
        # Attention: Replaces whitespaces with underscores
        username = generate_unique_username([basename])
        return username

    def get_settings(self):
        settings = {
            'VERIFIED_EMAIL': True,
        }
        provider_settings = super(ServiceKontoProvider, self).get_settings()
        settings.update(provider_settings)
        return settings<commit_msg>apps/servicekonto: Generate ID from email<commit_after>from allauth.socialaccount.providers.base import Provider
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.utils import generate_unique_username
from django.urls import reverse
from django.utils.http import urlencode


class ServiceKontoAccount(ProviderAccount):
    def to_str(self):
        return '%s' % (self.account.extra_data['email'])


class ServiceKontoProvider(Provider):
    id = 'servicekonto'
    name = 'Service-Konto'
    account_class = ServiceKontoAccount

    def get_login_url(self, request, **kwargs):
        url = reverse(self.id + "_login")
        if kwargs:
            url = url + '?' + urlencode(kwargs)
        return url

    def extract_uid(self, data):
        return data['email']

    def extract_common_fields(self, data):
        return {
            'username': generate_unique_username(data['email']),
            'email': data['email'],
        }

    def get_settings(self):
        settings = {
            'VERIFIED_EMAIL': True,
        }
        provider_settings = super(ServiceKontoProvider, self).get_settings()
        settings.update(provider_settings)
        return settings
{'fraction_non_alphanumeric': 0.10097154753643303, 'fraction_numerical': 0.0, 'mean_word_length': 2.875, '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': '2544506', 'n_tokens_mistral': 788, 'n_tokens_neox': 772, 'n_words': 172}