Skip to content
Snippets Groups Projects
Select Git revision
  • 033388c67bd05d9a7161545822a9eeb752d20fcf
  • main default protected
  • feature/export-filtering
  • feature/clear-schedule-button
  • fix/responsive-cols-in-polls
  • feature/preference-polling-form
  • feature/json-export-via-rest-framework
  • feature/json-schedule-import-tests
  • fix/add-room-import-only-once
  • ak-import
  • renovate/django-simple-history-3.x
  • renovate/django-debug-toolbar-4.x
  • renovate/django-5.x
  • renovate/mysqlclient-2.x
14 results

environment.py

Blame
  • Forked from KIF / AKPlanning
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    normalize.lua 1.30 KiB
    --[[
    return the field normalized (comma separated, single space)
    and add individual player names to recipient list
    --]]
    function mail.normalize_players_and_add_recipients(field, recipients)
        local order = mail.parse_player_list(field)
        for i,c in ipairs(order) do
            if recipients[string.lower(c)] == nil then
                recipients[string.lower(c)] = c
            end
        end
        return mail.concat_player_list(order)
    end
    
    
    function mail.parse_player_list(field)
        local separator = ", "
        local pattern = "([^" .. separator .. "]+)"
    
        -- get individual players
        local player_set = {}
        local order = {}
        field:gsub(pattern, function(c)
            if player_set[string.lower(c)] == nil then
                player_set[string.lower(c)] = c
                order[#order+1] = c
            end
        end)
    
        return order
    end
    
    function mail.concat_player_list(order)
        -- turn list of players back into normalized string
        return table.concat(order, ", ")
    end
    
    function mail.player_in_list(name, list)
        if type(list) == "string" then
            list = mail.parse_player_list(list)
        end
        for k,c in pairs(list) do
            if name == c then
                return true
            end
        end
        return false
    end
    
    
    function mail.ensure_new_format(message)
        if message.sender then
            message.to = name
        end
    end