<commit_before>lazuli = require "lazuli"
Profiles = require "models.profiles"
import respond_to from require "lapis.application"


class extends lazuli.Application
  @enable "user_management"

  @name: "profile_"
  @path: "/profile"

  [show: "/:id[%d]"]: =>
    @profiledata,err=Profiles\getOrCreateByUser tonumber @params.id
    if @profiledata
      return render: true
    else
      return status: 404, "Error 404: "..err

  [edit: "/edit"]: respond_to {
    GET: =>
      if @modules.user_management.currentuser
        @profiledata,err=Profiles\getOrCreateByUser @modules.user_management.currentuser
        return render: true
      else
        @session.login_redirect=@req.parsed_url.path
        return redirect_to: @url_for "lazuli_modules_usermanagement_login"
    POST: =>
      if @modules.user_management.currentuser
        @profiledata,err=Profiles\getOrCreateByUser @modules.user_management.currentuser
        @profiledata\update{
          about: @params.about
          birthday: @params.birthday
          privacy_birthday_dm: @params.privacy_birthday_dm or false
          privacy_birthday_y: @params.privacy_birthday_y or false
          privacy_birthday_age: @params.privacy_birthday_age or false
          gender: @params.gender
          privacy_gender: @params.privacy_gender or false
        }
        return render: true
      else
        @session.login_redirect=@req.parsed_url.path
        return redirect_to: @url_for "lazuli_modules_usermanagement_login"
  }<commit_msg>improved profile<commit_after>lazuli = require "lazuli"
Profiles = require "models.profiles"
import respond_to from require "lapis.application"

import NULL from require "lapis.db"

class extends lazuli.Application
  @enable "user_management"

  @name: "profile_"
  @path: "/profile"

  [show: "/:id[%d]"]: =>
    @profiledata,err=Profiles\getOrCreateByUser tonumber @params.id
    if @profiledata
      return render: true
    else
      return status: 404, "Error 404: "..err

  [edit: "/edit"]: respond_to {
    GET: =>
      if @modules.user_management.currentuser
        @profiledata,err=Profiles\getOrCreateByUser @modules.user_management.currentuser
        return render: true
      else
        @session.login_redirect=@req.parsed_url.path
        return redirect_to: @url_for "lazuli_modules_usermanagement_login"
    POST: =>
      if @modules.user_management.currentuser
        @profiledata,err=Profiles\getOrCreateByUser @modules.user_management.currentuser
        @profiledata\update{
          about: @params.about or NULL
          birthday: @params.birthday\find"%d%d%d%d-%d%d?-%d%d?" and @params.birthday or NULL
          privacy_birthday_dm: @params.privacy_birthday_dm and true or false
          privacy_birthday_y: @params.privacy_birthday_y and true or false
          privacy_birthday_age: @params.privacy_birthday_age and true or false
          gender: @params.gender or NULL
          privacy_gender: @params.privacy_gender and true or false
        }
        return render: true
      else
        @session.login_redirect=@req.parsed_url.path
        return redirect_to: @url_for "lazuli_modules_usermanagement_login"
  }
{'fraction_non_alphanumeric': 0.09243431465653688, 'fraction_numerical': 0.003798670465337132, 'mean_word_length': 3.2818428184281845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2309320', 'n_tokens_mistral': 1026, 'n_tokens_neox': 988, 'n_words': 204}