Commit f2ec5fe9 authored by Adam Rambousek's avatar Adam Rambousek
Browse files

User fixes

parent 6a731cab
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ class TeCu < DictSedna
      if xml != ''
        doc = load_xml_string(xml)
        eid = doc.root['id']
        rows = [ [eid,doc.root['abbr'],'','','','','','','','','','',''] ]
        rows = [ [eid,doc.root['abbrev'],'','','','','','','','','','',''] ]
        ri = 0
        doc.find('terms/term').each{|t|
          rows[ri] = ['','','','','','','','','','','',''] if rows[ri].nil?
@@ -653,6 +653,7 @@ class TeCu < DictSedna
      {'role'=>'jazyk_korektor','label'=>'Jazykový korektor'},
      {'role'=>'revizor','label'=>'Revizor'},
      {'role'=>'tajemnik','label'=>'Tajemník term. komise'},
      {'role'=>'blok','label'=>'zablokovaný uživatel'},
    ]
    settings['dictionaries'] = []
    @list_thes.each{|th|
@@ -874,12 +875,14 @@ class TeCu < DictSedna
    query = '/user[login!="nagios"]'
    query = '/user[login="'+username+'"]' if username != ''
    output = []
    begin
    userdict.xquery_to_array(query).each{|xml|
      doc = load_xml_string(xml)
      userhash = {'login'=>'', 'name'=>'', 'email'=>'', 'phone'=>'', 'organization'=>'', 'roles'=>[]}
      userhash['login'] = doc.find('/user/login').first.content.to_s
      next if userhash['login'] == 'read' and not all_users
      userhash['name'] = doc.find('/user/name').first.content.to_s unless doc.find('/user/name').first.nil?
      userhash['name'] = userhash['login']
      userhash['name'] = doc.find('/user/name').first.content.to_s if doc.find('/user/name').first != nil and doc.find('/user/name').first.content.to_s != ''
      userhash['prijmeni'] = userhash['name'].split(' ').last()
      userhash['email'] = doc.find('/user/email').first.content.to_s unless doc.find('/user/email').first.nil?
      userhash['phone'] = doc.find('/user/phone').first.content.to_s unless doc.find('/user/phone').first.nil?
@@ -887,6 +890,8 @@ class TeCu < DictSedna
      doc.find('/user/roles/role').each{|r| userhash['roles'] << r.content}
      output << userhash
    }
    rescue
    end
    return output.sort_by{|a| a['prijmeni'].to_s}
  end

+17 −10
Original line number Diff line number Diff line
@@ -360,9 +360,12 @@ def next_step(changes, status, schvaleni, wait_for, change_notes, user_roles, en
    }
  end
  if obor == ''
    if entry_hash['entry']['defs'] != nil 
      entry_hash['entry']['defs'].each{|edef|
        obor = '_' + edef['@obor'] if edef['@obor'] != ''
    if entry_hash['entry']['defs'] != nil and entry_hash['entry']['defs']['def'] != nil
      entry_hash['entry']['defs']['def'].each{|edef|
        $stderr.puts edef
        $stderr.puts edef.class
        $stderr.puts edef['@obor'].to_s
        obor = '_' + edef['@obor'].to_s if edef['@obor'].to_s != ''
      }
    end
  end
@@ -567,7 +570,7 @@ def add_history(entry_id, xml)
end

def finish_csv_term(termhash)
  termxml = '<entry id="'+termhash['id']+'" abbr="'+termhash['abbr']+'">'
  termxml = '<entry id="'+termhash['id']+'" abbrev="'+termhash['abbr']+'">'
  termxml +='<terms>'
  termhash['terms'].each{|t|
    termxml += '<term lang="'+t['lang'].gsub(/[^a-z]/,'')+'">'+t['term'].gsub('<','&lt;')+'</term>'
@@ -1024,6 +1027,7 @@ def do_GET(request, response)
    end
  when 'delete'
    id = request.query['id'].to_s.force_encoding("UTF-8")
    @dict_array['notification'].unlock_entry(id, user)
    if @dict_array['settings'].get_settings['dict']['simpleprocess'] == 'true'
      begin
        xml = @dict.get(id)
@@ -1052,7 +1056,7 @@ def do_GET(request, response)
        doc.find('notes').first << newnote
        @dict_array['tecuwork'].update(id, doc.to_s)
        term_cz = doc.find('terms/term[@lang="cz"]').first.content.to_s unless doc.find('terms/term[@lang="cz"]').first.nil?
        @dict_array['notification'].prepare_notif(id, term_cz, 'hl_redaktor,obor_redaktor,obor_revizor', 'navrh na zrušení termínu', user, @dict_array['tecu_user'])
        @dict_array['notification'].prepare_notif(id, term_cz, 'tajemnik', 'navrh na zrušení termínu', user, @dict_array['tecu_user'])
      end
      response.body = '{"ok":true, "msg":"saved", "id": "'+id+'"}'
      response['Content-Type'] = 'application/json; charset=utf-8'
@@ -1153,7 +1157,7 @@ def do_GET(request, response)
      termhash = {}
      t.each{|tr|
        next if tr[0].to_s.strip == 'id'
        if tr[0] != ''
        if tr[0].to_s != ''
          if termid != nil
            #ukoncit term
            data += finish_csv_term(termhash)
@@ -1588,7 +1592,7 @@ def do_GET(request, response)
      if request.query["id"].to_s != ""
        id = request.query["id"].to_s.force_encoding('UTF-8')
        workxml = @dict_array['tecuwork'].get(id)
        data_hash = CobraVsMongoose.xml_to_hash(workxml)
        data_hash = normalize_json(CobraVsMongoose.xml_to_hash(workxml))
        $stderr.puts data_hash
        if data_hash.nil? or data_hash == {}
          @dict_array['notification'].clear_notif(id)
@@ -1636,7 +1640,8 @@ def do_GET(request, response)
      if request.query["id"].to_s != ""
        id = request.query["id"].to_s.force_encoding('UTF-8')
        workxml = @dict_array['tecuwork'].get(id)
        data_hash = CobraVsMongoose.xml_to_hash(workxml)
        @dict_array['notification'].unlock_entry(id, user)
        data_hash = normalize_json(CobraVsMongoose.xml_to_hash(workxml))
        $stderr.puts data_hash
        if data_hash.nil? or data_hash == {}
          @dict_array['notification'].clear_notif(id)
@@ -1670,6 +1675,7 @@ def do_GET(request, response)
        }
        data_hash['entry']['@schvaleno_role'] = schvalene_role.join(';')
        #status?
        $stderr.puts data_hash
        new_status, wait_for = next_step([], data_hash['entry']['@status'].to_s, data_hash['entry']['schvaleni'].to_s, data_hash['entry']['@wait_for'].join(','), data_hash['entry']['notes']['note'], @dict.get_users(@dict_array['tecu_user'], user)[0]['roles'], data_hash)
        $stderr.puts data_hash['entry']['@status'].to_s + ' - ' + data_hash['entry']['schvaleni'].to_s
        $stderr.puts new_status + ' - ' + wait_for
@@ -1748,7 +1754,8 @@ def do_GET(request, response)
      if request.query["id"].to_s != ""
        id = request.query["id"].to_s.force_encoding('UTF-8')
        workxml = @dict_array['tecuwork'].get(id)
        data_hash = CobraVsMongoose.xml_to_hash(workxml)
        @dict_array['notification'].unlock_entry(id, user)
        data_hash = normalize_json(CobraVsMongoose.xml_to_hash(workxml))
        if data_hash.nil? or data_hash == {}
          @dict_array['notification'].clear_notif(id)
          response.body = '{"ok":true, "msg":"saved", "id": "'+id+'"}'