Repository: CSCfi/rems
Pull request #1543 (2019-08-27 17:11:02)

Remove non-localized fields from license
# Definition of Done / Review checklist

## Reviewability
- [x] link to issue
- [x] note if PR is on top of other PR
- [x] note if related change in rems-deploy repo
- [x] consider adding screenshots for ease of review

## API
- [x] API is documented and shows up in Swagger UI
- [x] API is backwards compatible or completely new
- [x] Events are backwards compatible

## Documentation
- [x] update changelog if necessary
- [x] add or update docstrings for namespaces and functions
- [x] components are added to guide page
- [x] documentation _at least_ for config options (i.e. docs folder)
- [x] ADR for major architectural decisions or experiments

## Different installations
- [x] new configuration options added to rems-deploy repository
- [x] instance specific translations (i.e. LBR kielivara)

## Testing
- [x] complex logic is unit tested
- [x] valuable features are integration / browser / acceptance tested automatically

## Accessibility
- [x] all icons have the aria-label attribute
- [x] all fields have a label
- [x] errors are linked to fields with aria-describedby
- [x] contrast is checked
- [x] conscious decision about where to move focus after an action

## Follow-up
- [x] new tasks are created for pending or remaining tasks
- [x] no critical TODOs left to implement



Patch:
diff --git a/resources/migrations/20190827120000-drop-license-title.down.sql b/resources/migrations/20190827120000-drop-license-title.down.sql
new file mode 100644
index 000000000..e09d86eeb
--- /dev/null
+++ b/resources/migrations/20190827120000-drop-license-title.down.sql
@@ -0,0 +1,7 @@
+ALTER TABLE license ADD title varchar(256) DEFAULT '' NOT NULL
+--;;
+ALTER TABLE license ALTER COLUMN title SET NOT NULL;
+--;;
+ALTER TABLE license ADD textcontent varchar(16384) DEFAULT NULL;
+--;;
+ALTER TABLE license ADD attachmentid integer DEFAULT NULL;
diff --git a/resources/migrations/20190827120000-drop-license-title.up.sql b/resources/migrations/20190827120000-drop-license-title.up.sql
new file mode 100644
index 000000000..3667839bb
--- /dev/null
+++ b/resources/migrations/20190827120000-drop-license-title.up.sql
@@ -0,0 +1,5 @@
+ALTER TABLE license DROP COLUMN title;
+--;;
+ALTER TABLE license DROP COLUMN textcontent;
+--;;
+ALTER TABLE license DROP COLUMN attachmentid;
diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql
index 0e672a105..da318eff6 100644
--- a/resources/sql/queries.sql
+++ b/resources/sql/queries.sql
@@ -249,10 +249,9 @@ WHERE appid = :application-id;
 
 -- :name create-license! :insert
 INSERT INTO license
-(ownerUserId, modifierUserId, title, type, textcontent, attachmentId)
+(ownerUserId, modifierUserId, type)
 VALUES
-(:owneruserid, :modifieruserid, :title, :type::license_type, :textcontent,
-/*~ (if (:attachmentId params) */ :attachmentId /*~*/ NULL /*~ ) ~*/);
+(:owneruserid, :modifieruserid, :type::license_type)
 
 -- :name set-license-state! :!
 UPDATE license
@@ -348,12 +347,12 @@ FROM workflow wf;
 -- - Gets application licenses by workflow and catalogue item ids
 -- - :wfid workflow id for workflow licenses
 -- - :items vector of catalogue item ids for resource licenses
-SELECT lic.id, lic.title, lic.type, lic.textcontent, lic.enabled, lic.archived
+SELECT lic.id, lic.type, lic.enabled, lic.archived
 FROM license lic
 INNER JOIN workflow_licenses wl ON lic.id = wl.licid
 WHERE wl.wfid = :wfid
 UNION
-SELECT lic.id, lic.title, lic.type, lic.textcontent, lic.enabled, lic.archived
+SELECT lic.id, lic.type, lic.enabled, lic.archived
 FROM license lic
 INNER JOIN resource_licenses rl ON lic.id = rl.licid
 INNER JOIN catalogue_item item ON (item.resid = rl.resid)
@@ -361,17 +360,17 @@ WHERE item.id IN (:v*:items)
 ORDER BY id;
 
 -- :name get-resource-licenses :? :*
-SELECT lic.id, lic.title, lic.type, lic.textcontent, lic.enabled, lic.archived
+SELECT lic.id, lic.type, lic.enabled, lic.archived
 FROM license lic
 INNER JOIN resource_licenses rl ON lic.id = rl.licid
 WHERE rl.resid = :id;
 
 -- :name get-all-licenses :? :*
-SELECT lic.id, lic.title, lic.type, lic.textcontent, lic.enabled, lic.archived, lic.attachmentid
+SELECT lic.id, lic.type, lic.enabled, lic.archived
 FROM license lic;
 
 -- :name get-license :? :1
-SELECT lic.id, lic.title, lic.type, lic.textcontent, lic.enabled, lic.archived, lic.attachmentid
+SELECT lic.id, lic.type, lic.enabled, lic.archived
 FROM license lic
 WHERE lic.id = :id;
 
diff --git a/src/clj/rems/api/licenses.clj b/src/clj/rems/api/licenses.clj
index 9e6f2d5f8..829da377c 100644
--- a/src/clj/rems/api/licenses.clj
+++ b/src/clj/rems/api/licenses.clj
@@ -13,9 +13,6 @@
 
 (s/defschema CreateLicenseCommand
   {:licensetype (s/enum "link" "text" "attachment")
-   :title s/Str
-   :textcontent s/Str
-   (s/optional-key :attachment-id) (s/maybe s/Int)
    :localizations {s/Keyword {:title s/Str
                               :textcontent s/Str
                               (s/optional-key :attachment-id) (s/maybe s/Int)}}})
@@ -55,7 +52,7 @@
       (ok (licenses/create-license! command (getx-user-id))))
 
     (PUT "/update" []
-      :summary "Update workflow"
+      :summary "Update license"
       :roles #{:owner}
       :body [command UpdateStateCommand]
       :return SuccessResponse
diff --git a/src/clj/rems/api/schema.clj b/src/clj/rems/api/schema.clj
index b897a6372..737e95b15 100644
--- a/src/clj/rems/api/schema.clj
+++ b/src/clj/rems/api/schema.clj
@@ -27,9 +27,6 @@
    :licensetype (s/enum "text" "link" "attachment")
    :enabled s/Bool
    :archived s/Bool
-   :title s/Str
-   :textcontent s/Str
-   (s/optional-key :attachment-id) (s/maybe s/Int)
    :localizations {s/Keyword {:title s/Str
                               :textcontent s/Str
                               (s/optional-key :attachment-id) (s/maybe s/Int)}}})
diff --git a/src/clj/rems/api/services/licenses.clj b/src/clj/rems/api/services/licenses.clj
index d75dc7b8f..c06ae1f82 100644
--- a/src/clj/rems/api/services/licenses.clj
+++ b/src/clj/rems/api/services/licenses.clj
@@ -7,13 +7,10 @@
             [rems.db.workflow :as workflow])
   (:import (java.io FileInputStream ByteArrayOutputStream)))
 
-(defn create-license! [{:keys [title licensetype textcontent localizations attachment-id]} user-id]
+(defn create-license! [{:keys [licensetype localizations]} user-id]
   (let [license (db/create-license! {:owneruserid user-id
                                      :modifieruserid user-id
-                                     :type licensetype
-                                     :title title
-                                     :textcontent textcontent
-                                     :attachmentId attachment-id})
+                                     :type licensetype})
         licid (:id license)]
     (doseq [[langcode localization] localizations]
       (db/create-license-localization! {:licid licid
diff --git a/src/clj/rems/application/model.clj b/src/clj/rems/application/model.clj
index 4bec62b9d..afae5ea1e 100644
--- a/src/clj/rems/application/model.clj
+++ b/src/clj/rems/application/model.clj
@@ -469,21 +469,16 @@
                                   (let [license-type (keyword (:licensetype license))]
                                     (merge {:license/id (:id license)
                                             :license/type license-type
-                                            :license/title (assoc (localization-for :title license)
-                                                                  :default (:title license))
+                                            :license/title (localization-for :title license)
                                             ;; TODO: remove unused keys
                                             :license/enabled (:enabled license)
                                             :license/archived (:archived license)}
                                            (case license-type
-                                             :text {:license/text (assoc (localization-for :textcontent license)
-                                                                         :default (:textcontent license))}
-                                             :link {:license/link (assoc (localization-for :textcontent license)
-                                                                         :default (:textcontent license))}
-                                             :attachment {:license/attachment-id (assoc (localization-for :attachment-id license)
-                                                                                        :default (:attachment-id license))
+                                             :text {:license/text (localization-for :textcontent license)}
+                                             :link {:license/link (localization-for :textcontent license)}
+                                             :attachment {:license/attachment-id (localization-for :attachment-id license)
                                                           ;; TODO: remove filename as unused?
-                                                          :license/attachment-filename (assoc (localization-for :textcontent license)
-                                                                                              :default (:textcontent license))})))))
+                                                          :license/attachment-filename (localization-for :textcontent license)})))))
                            (sort-by :license/id))]
     (merge-lists-by :license/id rich-licenses app-licenses)))
 
diff --git a/src/clj/rems/db/licenses.clj b/src/clj/rems/db/licenses.clj
index 7e42842a4..f9cc91516 100644
--- a/src/clj/rems/db/licenses.clj
+++ b/src/clj/rems/db/licenses.clj
@@ -7,11 +7,7 @@
   {:id (:id license)
    :licensetype (:type license)
    :enabled (:enabled license)
-   :archived (:archived license)
-   ;; TODO why do licenses have a non-localized title & content while items don't?
-   :title (:title license)
-   :textcontent (:textcontent license)
-   :attachment-id (:attachmentid license)})
+   :archived (:archived license)})
 
 (defn- format-licenses [licenses]
   (mapv format-license licenses))
diff --git a/src/cljc/rems/text.cljc b/src/cljc/rems/text.cljc
index c361382ad..92614fe6a 100644
--- a/src/cljc/rems/text.cljc
+++ b/src/cljc/rems/text.cljc
@@ -45,10 +45,6 @@
   (let [lang #?(:clj context/*lang*
                 :cljs @(rf/subscribe [:language]))]
     (or (get m lang)
-        ;; TODO: After all non-localized titles have been removed and guaranteed
-        ;;   that the localizations exist for all languages, this :default
-        ;;   fallback can be removed.
-        (get m :default)
         (first (vals m)))))
 
 ;; TODO: replace usages of `get-localized-title` with `localized`
@@ -109,9 +105,3 @@
      :cljs (let [time (if (string? time) (format/parse time) time)]
              (when time
                (format/unparse-local time-format (time/to-default-time-zone time))))))
-
-(defn localize-item
-  ([item]
-   #?(:cljs (localize-item item @(rf/subscribe [:language]))))
-  ([item language]
-   #?(:cljs (merge item (get-in item [:localizations language])))))
diff --git a/src/cljs/rems/actions/add_licenses.cljs b/src/cljs/rems/actions/add_licenses.cljs
index 0ad79cffd..8ee884f61 100644
--- a/src/cljs/rems/actions/add_licenses.cljs
+++ b/src/cljs/rems/actions/add_licenses.cljs
@@ -4,7 +4,7 @@
             [rems.actions.action :refer [action-button action-form-view action-comment button-wrapper collapse-action-form]]
             [rems.dropdown :as dropdown]
             [rems.status-modal :as status-modal]
-            [rems.text :refer [text]]
+            [rems.text :refer [text get-localized-title]]
             [rems.util :refer [fetch post!]]))
 
 (rf/reg-fx
@@ -64,10 +64,6 @@
                   :text (text :t.actions/add-licenses)
                   :on-click #(rf/dispatch [::open-form])}])
 
-(defn- title-of-license [license language]
-  (or (get-in license [:localizations language :title])
-      (:title license)))
-
 (defn add-licenses-view
   [{:keys [selected-licenses potential-licenses comment language on-set-comment on-set-licenses on-send]}]
   [action-form-view action-form-id
@@ -87,7 +83,7 @@
       {:id dropdown-id
        :items potential-licenses
        :item-key :id
-       :item-label #(title-of-license % language)
+       :item-label #(get-localized-title % language)
        :item-selected? #(contains? (set selected-licenses) %)
        :multi? true
        :on-change on-set-licenses}]]]])
diff --git a/src/cljs/rems/administration/create_license.cljs b/src/cljs/rems/administration/create_license.cljs
index 040871cb3..cb199a8e7 100644
--- a/src/cljs/rems/administration/create_license.cljs
+++ b/src/cljs/rems/administration/create_license.cljs
@@ -6,7 +6,7 @@
             [rems.atoms :as atoms :refer [file-download document-title]]
             [rems.collapsible :as collapsible]
             [rems.status-modal :as status-modal]
-            [rems.text :refer [text localize-item]]
+            [rems.text :refer [text]]
             [rems.util :refer [dispatch! post!]]))
 
 (rf/reg-event-db
@@ -49,14 +49,13 @@
           (set (keys (:localizations request))))
        (every? valid-localization? (vals (:localizations request)))))
 
-(defn build-request [form default-language languages]
+(defn build-request [form languages]
   (let [license-type (:licensetype form)
         request {:licensetype license-type
                  :localizations (into {} (map (fn [[lang data]]
                                                 [lang (build-localization data license-type)])
                                               (:localizations form)))}]
-    (when (valid-request? request languages)
-      (localize-item request default-language))))
+    (when (valid-request? request languages) request)))
 
 (rf/reg-event-fx
  ::create-license
@@ -180,9 +179,8 @@
 
 (defn- save-license-button [on-click]
   (let [form @(rf/subscribe [::form])
-        default-language @(rf/subscribe [:default-language])
         languages @(rf/subscribe [:languages])
-        request (build-request form default-language languages)]
+        request (build-request form languages)]
     [:button.btn.btn-primary
      {:type :button
       :on-click (fn []
diff --git a/src/cljs/rems/administration/create_resource.cljs b/src/cljs/rems/administration/create_resource.cljs
index da760e914..a0aebb9dc 100644
--- a/src/cljs/rems/administration/create_resource.cljs
+++ b/src/cljs/rems/administration/create_resource.cljs
@@ -8,7 +8,7 @@
             [rems.dropdown :as dropdown]
             [rems.spinner :as spinner]
             [rems.status-modal :as status-modal]
-            [rems.text :refer [text localize-item]]
+            [rems.text :refer [text get-localized-title]]
             [rems.util :refer [dispatch! fetch post!]]))
 
 (rf/reg-event-fx
@@ -92,14 +92,15 @@
 
 (defn- resource-licenses-field []
   (let [available-licenses @(rf/subscribe [::licenses])
-        selected-licenses @(rf/subscribe [::selected-licenses])]
+        selected-licenses @(rf/subscribe [::selected-licenses])
+        language @(rf/subscribe [:language])]
     [:div.form-group
      [:label {:for licenses-dropdown-id} (text :t.create-resource/licenses-selection)]
      [dropdown/dropdown
       {:id licenses-dropdown-id
-       :items (map localize-item available-licenses)
+       :items available-licenses
        :item-key :id
-       :item-label :title
+       :item-label #(get-localized-title % language)
        :item-selected? #(contains? (set selected-licenses) %)
        :multi? true
        :on-change #(rf/dispatch [::set-licenses %])}]]))
diff --git a/src/cljs/rems/administration/license.cljs b/src/cljs/rems/administration/license.cljs
index 594b96904..e155c43d8 100644
--- a/src/cljs/rems/administration/license.cljs
+++ b/src/cljs/rems/administration/license.cljs
@@ -6,7 +6,7 @@
             [rems.atoms :as atoms :refer [attachment-link external-link readonly-checkbox document-title]]
             [rems.collapsible :as collapsible]
             [rems.spinner :as spinner]
-            [rems.text :refer [localize-time text text-format]]
+            [rems.text :refer [get-localized-title localize-time text text-format]]
             [rems.util :refer [dispatch! fetch]]))
 
 (rf/reg-event-fx
@@ -36,14 +36,13 @@
    "/#/administration/licenses"
    (text :t.administration/back)])
 
-(defn license-view [license language]
+(defn- license-view [license language]
   [:div.spaced-vertically-3
    [collapsible/component
     {:id "license"
-     :title [:span (get-in license [:localizations language :title] (:title license))]
+     :title [:span (get-localized-title license language)]
      :always (into [:div]
                    (concat
-                    [[inline-info-field (text :t.administration/title) (:title license)]]
                     (for [[langcode localization] (:localizations license)]
                       [inline-info-field (str (text :t.administration/title)
                                               " (" (str/upper-case (name langcode)) ")")
@@ -75,6 +74,52 @@
                      [inline-info-field (text :t.administration/active) [readonly-checkbox (not (:expired license))]]]))}]
    [:div.col.commands [back-button]]])
 
+;; XXX: Duplicates much of license-view. One notable difference is that
+;;      here the license text is only shown in the current language.
+(defn- license-view-compact [license language]
+  (into [:div.form-item
+         [:h3 (text-format :t.administration/license-field (get-localized-title license language))]]
+        (concat (for [[langcode localization] (:localizations license)]
+                  [inline-info-field
+                   (str (text :t.administration/title)
+                        " (" (str/upper-case (name langcode)) ")")
+                   (:title localization)])
+                [[inline-info-field (text :t.administration/type) (:licensetype license)]]
+                (when (= "link" (:licensetype license))
+                  (for [[langcode localization] (:localizations license)]
+                    [inline-info-field
+                     (str (text :t.create-license/external-link)
+                          " (" (str/upper-case (name langcode)) ")")
+                     [:a {:target :_blank :href (:textcontent localization)}
+                      (:textcontent localization) " " [external-link]]]))
+                (when (= "text" (:licensetype license))
+                  (let [localization (get-in license [:localizations language])]
+                    (when (:textcontent localization)
+                      [[inline-info-field (text :t.create-license/license-text)
+                        (:textcontent localization)]])))
+                (when (= "attachment" (:licensetype license))
+                  (for [[langcode localization] (:localizations license)]
+                    (when (:attachment-id localization)
+                      [inline-info-field
+                       (str (text :t.create-license/license-attachment)
+                            " (" (str/upper-case (name langcode)) ")")
+                       [attachment-link (:attachment-id localization) (:title localization)]
+                       {:box? false}])))
+                [[inline-info-field (text :t.administration/start) (localize-time (:start license))]
+                 [inline-info-field (text :t.administration/end) (localize-time (:end license))]])))
+
+(defn licenses-view [licenses language]
+  [collapsible/component
+   {:id "licenses"
+    :title (text :t.administration/licenses)
+    :top-less-button? (> (count licenses) 5)
+    :open? (<= (count licenses) 5)
+    :collapse (if (seq licenses)
+                (into [:div]
+                      (for [license licenses]
+                        [license-view-compact license language]))
+                [:p (text :t.administration/no-licenses)])}])
+
 (defn license-page []
   (let [license (rf/subscribe [::license])
         language (rf/subscribe [:language])
diff --git a/src/cljs/rems/administration/licenses.cljs b/src/cljs/rems/administration/licenses.cljs
index 50d12689c..7119f3125 100644
--- a/src/cljs/rems/administration/licenses.cljs
+++ b/src/cljs/rems/administration/licenses.cljs
@@ -71,7 +71,7 @@
  (fn [[licenses language] _]
    (map (fn [license]
           {:key (:id license)
-           :title {:value (get-localized-title license language)} ; XXX: not really catalogue item, but the structure is the same
+           :title {:value (get-localized-title license language)}
            :type {:value (:licensetype license)}
            :start (let [value (:start license)]
                     {:value value
diff --git a/src/cljs/rems/administration/resource.cljs b/src/cljs/rems/administration/resource.cljs
index 32e1d8134..60fef7e9a 100644
--- a/src/cljs/rems/administration/resource.cljs
+++ b/src/cljs/rems/administration/resource.cljs
@@ -3,11 +3,12 @@
             [re-frame.core :as rf]
             [rems.administration.administration :refer [administration-navigator-container]]
             [rems.administration.components :refer [inline-info-field]]
+            [rems.administration.license :refer [licenses-view]]
             [rems.atoms :as atoms :refer [attachment-link external-link readonly-checkbox document-title]]
             [rems.collapsible :as collapsible]
             [rems.common-util :refer [andstr]]
             [rems.spinner :as spinner]
-            [rems.text :refer [localize-time text text-format]]
+            [rems.text :refer [get-localized-title localize-time text text-format]]
             [rems.util :refer [dispatch! fetch]]))
 
 (rf/reg-event-fx
@@ -37,55 +38,6 @@
    "/#/administration/resources"
    (text :t.administration/back)])
 
-(defn license-view [license language]
-  (into [:div.form-item
-         [:h3 (text-format :t.administration/license-field (get-in license [:localizations language :title]))]
-         [inline-info-field (text :t.administration/title) (:title license)]]
-        (concat (for [[langcode localization] (:localizations license)]
-                  [inline-info-field
-                   (str (text :t.administration/title)
-                        " (" (str/upper-case (name langcode)) ")")
-                   (:title localization)])
-                [[inline-info-field (text :t.administration/type) (:licensetype license)]
-                 (case (:licensetype license)
-                   "link" [inline-info-field
-                           (text :t.create-license/external-link)
-                           [:a {:target :_blank :href (:textcontent license)}
-                            (:textcontent license) " " [external-link]]]
-                   "text" [inline-info-field
-                           (text :t.create-license/license-text)
-                           (:textcontent license)]
-                   nil)]
-                (when (= "link" (:licensetype license))
-                  (for [[langcode localization] (:localizations license)]
-                    [inline-info-field
-                     (str (text :t.create-license/external-link)
-                          " (" (str/upper-case (name langcode)) ")")
-                     [:a {:target :_blank :href (:textcontent localization)}
-                      (:textcontent localization) " " [external-link]]]))
-                (when (= "attachment" (:licensetype license))
-                  (for [[langcode localization] (:localizations license)]
-                    (when (:attachment-id localization)
-                      [inline-info-field
-                       (str (text :t.create-license/license-attachment)
-                            " (" (str/upper-case (name langcode)) ")")
-                       [attachment-link (:attachment-id localization) (:title localization)]
-                       {:box? false}])))
-                [[inline-info-field (text :t.administration/start) (localize-time (:start license))]
-                 [inline-info-field (text :t.administration/end) (localize-time (:end license))]])))
-
-(defn licenses-view [licenses language]
-  [collapsible/component
-   {:id "licenses"
-    :title (text :t.administration/licenses)
-    :top-less-button? (> (count licenses) 5)
-    :open? (<= (count licenses) 5)
-    :collapse (if (seq licenses)
-                (into [:div]
-                      (for [license licenses]
-                        [license-view license language]))
-                [:p (text :t.administration/no-licenses)])}])
-
 (defn resource-view [resource language]
   [:div.spaced-vertically-3
    [collapsible/component
diff --git a/src/cljs/rems/administration/workflow.cljs b/src/cljs/rems/administration/workflow.cljs
index 8e4d6cee5..3f363278d 100644
--- a/src/cljs/rems/administration/workflow.cljs
+++ b/src/cljs/rems/administration/workflow.cljs
@@ -3,11 +3,12 @@
             [re-frame.core :as rf]
             [rems.administration.administration :refer [administration-navigator-container]]
             [rems.administration.components :refer [inline-info-field]]
+            [rems.administration.license :refer [licenses-view]]
             [rems.atoms :as atoms :refer [attachment-link external-link info-field readonly-checkbox enrich-user document-title]]
             [rems.collapsible :as collapsible]
             [rems.common-util :refer [andstr]]
             [rems.spinner :as spinner]
-            [rems.text :refer [localize-time text text-format]]
+            [rems.text :refer [get-localized-title localize-time text text-format]]
             [rems.util :refer [dispatch! fetch]]))
 
 (rf/reg-event-fx
@@ -42,61 +43,6 @@
    (str "/#/administration/edit-workflow/" id)
    (text :t.administration/edit)])
 
-(defn get-localized-value [field key language]
-  (key (first (filter (comp #{(name language)} :langcode)
-                      (:localizations field)))))
-
-;; TODO try to unify with resource license-view
-(defn license-view [license language]
-  (into [:div.form-item
-         [:h3 (text-format :t.administration/license-field (get-localized-value license :title language))]
-         [inline-info-field (text :t.administration/title) (:title license)]]
-        (concat (for [localization (:localizations license)]
-                  [inline-info-field (str (text :t.administration/title)
-                                          " "
-                                          (str/upper-case (:langcode localization))) (:title localization)])
-                [[inline-info-field (text :t.administration/type) (:type license)]
-                 (when (:textcontent license)
-                   (case (:type license)
-                     "link" [inline-info-field (text :t.create-license/external-link)
-                             [:a {:target :_blank
-                                  :href (:textcontent license)}
-                              (:textcontent license) " " [external-link]]]
-                     "text" [inline-info-field (text :t.create-license/license-text) (:textcontent license)]
-                     nil))]
-                (when (= "link" (:type license))
-                  (for [localization (:localizations license)]
-                    [inline-info-field (str (text :t.create-license/external-link)
-                                            " "
-                                            (str/upper-case (:langcode localization)))
-                     [:a {:target :_blank
-                          :href (:textcontent localization)}
-                      (:textcontent localization) " " [external-link]]]))
-                (when (= "attachment" (:licensetype license))
-                  (for [localization (:localizations license)]
-                    (when (:attachment-id localization)
-                      [inline-info-field
-                       (str (text :t.create-license/license-attachment)
-                            " "
-                            (str/upper-case (:langcode localization)))
-                       [attachment-link (:attachment-id localization) (:title localization)]
-                       {:box? false}])))
-                [[inline-info-field (text :t.administration/start) (localize-time (:start license))]
-                 [inline-info-field (text :t.administration/end) (localize-time (:end license))]])))
-
-(defn licenses-view [licenses language]
-  [collapsible/component
-   {:id "licenses"
-    :title (text :t.administration/licenses)
-    :top-less-button? (> (count licenses) 5)
-    :open? (<= (count licenses 5))
-    :collapse
-    (if (seq licenses)
-      (into [:div]
-            (for [license licenses]
-              [license-view license language]))
-      [:p (text :t.administration/no-licenses)])}])
-
 (defn workflow-view [workflow language]
   [:div.spaced-vertically-3
    [collapsible/component
diff --git a/src/cljs/rems/application.cljs b/src/cljs/rems/application.cljs
index 1dfa2dca2..c79ba841b 100644
--- a/src/cljs/rems/application.cljs
+++ b/src/cljs/rems/application.cljs
@@ -26,7 +26,7 @@
             [rems.phase :refer [phases]]
             [rems.spinner :as spinner]
             [rems.status-modal :as status-modal]
-            [rems.text :refer [localize-decision localize-event localized localize-item localize-state localize-time text text-format get-localized-title]]
+            [rems.text :refer [localize-decision localize-event localized localize-state localize-time text text-format]]
             [rems.util :refer [dispatch! fetch parse-int post! in-page-anchor-link]])
   (:require-macros [rems.guide-macros :refer [component-info example]]))
 


Test patch:
diff --git a/src/clj/rems/db/test_data.clj b/src/clj/rems/db/test_data.clj
index c173c9b7c..1e02231a5 100644
--- a/src/clj/rems/db/test_data.clj
+++ b/src/clj/rems/db/test_data.clj
@@ -86,8 +86,6 @@
                         :license/keys [type title link text]
                         :as command}]
   (let [result (licenses/create-license! {:licensetype (name (or type :text))
-                                          :title ""
-                                          :textcontent ""
                                           :localizations
                                           (transpose-localizations {:title title
                                                                     :textcontent (merge link text)})}
@@ -216,8 +214,12 @@
     (form/update-form! {:id id :enabled true :archived true})))
 
 (defn- create-disabled-license! [owner]
-  (let [id (:id (db/create-license! {:modifieruserid owner :owneruserid owner
-                                     :title "expired license" :type "link" :textcontent "http://expired"}))]
+  (let [id (create-license! {:actor owner
+                             :license/type "link"
+                             :license/title {:en "Disabled license"
+                                             :fi "Käytöstä poistettu lisenssi"}
+                             :license/link {:en "http://disabled"
+                                            :fi "http://disabled"}})]
     (db/set-license-state! {:id id :enabled false :archived false})))
 
 (defn- create-basic-form!
diff --git a/test/clj/rems/api/test_administration.clj b/test/clj/rems/api/test_administration.clj
index 4fadd4a16..73ceba02a 100644
--- a/test/clj/rems/api/test_administration.clj
+++ b/test/clj/rems/api/test_administration.clj
@@ -16,7 +16,7 @@
 (deftest test-archiving-disabling
   (let [api-key "42"
         user-id "owner"
-        license-id (:id (api-call :post "/api/licenses/create" {:licensetype "text" :title "x" :textcontent "x" :localizations {}}
+        license-id (:id (api-call :post "/api/licenses/create" {:licensetype "text" :localizations {}}
                                   api-key user-id))
         resource-id (:id (api-call :post "/api/resources/create" {:resid "test" :organization "abc" :licenses [license-id]}
                                    api-key user-id))
diff --git a/test/clj/rems/api/test_licenses.clj b/test/clj/rems/api/test_licenses.clj
index 74dcb881a..2c5d269fa 100644
--- a/test/clj/rems/api/test_licenses.clj
+++ b/test/clj/rems/api/test_licenses.clj
@@ -2,8 +2,7 @@
   (:require [clojure.test :refer :all]
             [rems.handler :refer [handler]]
             [rems.api.testing :refer :all]
-            [ring.mock.request :refer :all])
-  (:import (java.util UUID)))
+            [ring.mock.request :refer :all]))
 
 (use-fixtures
   :once
@@ -28,10 +27,7 @@
         (is (:id (first data)))))
 
     (testing "create linked license"
-      (let [command {:title (str "license title " (UUID/randomUUID))
-                     :licensetype "link"
-                     :textcontent "http://example.com/license"
-                     :attachment-id nil
+      (let [command {:licensetype "link"
                      :localizations {:en {:title "en title"
                                           :textcontent "http://example.com/license/en"
                                           :attachment-id nil}
@@ -56,10 +52,7 @@
             (is (= command (select-keys license (keys command))))))))
 
     (testing "create inline license"
-      (let [command {:title (str "license title " (UUID/randomUUID))
-                     :licensetype "text"
-                     :textcontent "license text"
-                     :attachment-id nil
+      (let [command {:licensetype "text"
                      :localizations {:en {:title "en title"
                                           :textcontent "en text"
                                           :attachment-id nil}
@@ -120,10 +113,7 @@
                               handler
                               read-ok-body
                               :id)
-            command {:title (str "license title " (UUID/randomUUID))
-                     :licensetype "text"
-                     :textcontent "license text"
-                     :attachment-id attachment-id
+            command {:licensetype "text"
                      :localizations {:en {:title "en title"
                                           :textcontent "en text"
                                           :attachment-id attachment-id}
@@ -177,8 +167,6 @@
     (testing "create"
       (let [response (-> (request :post "/api/licenses/create")
                          (json-body {:licensetype "text"
-                                     :title "t"
-                                     :textcontent "t"
                                      :localizations {:en {:title "t"
                                                           :textcontent "t"}}})
                          handler)]
@@ -196,8 +184,6 @@
       (let [response (-> (request :post "/api/licenses/create")
                          (authenticate "42" "alice")
                          (json-body {:licensetype "text"
-                                     :title "t"
-                                     :textcontent "t"
                                      :localizations {:en {:title "t"
                                                           :textcontent "t"}}})
                          handler)]
diff --git a/test/clj/rems/application/test_model.clj b/test/clj/rems/application/test_model.clj
index 606de1473..936c8c45d 100644
--- a/test/clj/rems/application/test_model.clj
+++ b/test/clj/rems/application/test_model.clj
@@ -86,8 +86,6 @@
 (def ^:private get-license
   {30 {:id 30
        :licensetype "link"
-       :title "non-localized title"
-       :textcontent "http://non-localized-license-link"
        :localizations {:en {:title "en title"
                             :textcontent "http://en-license-link"}
                        :fi {:title "fi title"
@@ -96,8 +94,6 @@
        :archived false}
    31 {:id 31
        :licensetype "text"
-       :title "non-localized title"
-       :textcontent "non-localized license text"
        :localizations {:en {:title "en title"
                             :textcontent "en license text"}
                        :fi {:title "fi title"
@@ -106,9 +102,6 @@
        :archived false}
    32 {:id 32
        :licensetype "attachment"
-       :title "non-localized title"
-       :textcontent "non-localized filename"
-       :attachment-id 3200
        :localizations {:en {:title "en title"
                             :textcontent "en filename"
                             :attachment-id 3201}
@@ -119,9 +112,6 @@
        :archived false}
    33 {:id 33
        :licensetype "attachment"
-       :title "non-localized title"
-       :textcontent "non-localized filename"
-       :attachment-id 3300
        :localizations {:en {:title "en title"
                             :textcontent "en filename"
                             :attachment-id 3301}
@@ -132,9 +122,6 @@
        :archived false}
    34 {:id 34
        :licensetype "attachment"
-       :title "non-localized title"
-       :textcontent "non-localized filename"
-       :attachment-id 3400
        :localizations {:en {:title "en title"
                             :textcontent "en filename"
                             :attachment-id 3401}
@@ -252,34 +239,27 @@
                                   :application/licenses [{:license/id 30
                                                           :license/type :link
                                                           :license/title {:en "en title"
-                                                                          :fi "fi title"
-                                                                          :default "non-localized title"}
+                                                                          :fi "fi title"}
                                                           :license/link {:en "http://en-license-link"
-                                                                         :fi "http://fi-license-link"
-                                                                         :default "http://non-localized-license-link"}
+                                                                         :fi "http://fi-license-link"}
                                                           :license/enabled true
                                                           :license/archived false}
                                                          {:license/id 31
                                                           :license/type :text
                                                           :license/title {:en "en title"
-                                                                          :fi "fi title"
-                                                                          :default "non-localized title"}
+                                                                          :fi "fi title"}
                                                           :license/text {:en "en license text"
-                                                                         :fi "fi license text"
-                                                                         :default "non-localized license text"}
+                                                                         :fi "fi license text"}
                                                           :license/enabled true
                                                           :license/archived false}
                                                          {:license/id 32
                                                           :license/type :attachment
                                                           :license/title {:en "en title"
-                                                                          :fi "fi title"
-                                                                          :default "non-localized title"}
+                                                                          :fi "fi title"}
                                                           :license/attachment-id {:en 3201
-                                                                                  :fi 3202
-                                                                                  :default 3200}
+                                                                                  :fi 3202}
                                                           :license/attachment-filename {:en "en filename"
-                                                                                        :fi "fi filename"
-                                                                                        :default "non-localized filename"}
+                                                                                        :fi "fi filename"}
                                                           :license/enabled true
                                                           :license/archived false}]
                                   :application/accepted-licenses {}
@@ -410,14 +390,11 @@
                                                                                       {:license/id 34
                                                                                        :license/type :attachment
                                                                                        :license/title {:en "en title"
-                                                                                                       :fi "fi title"
-                                                                                                       :default "non-localized title"}
+                                                                                                       :fi "fi title"}
                                                                                        :license/attachment-id {:en 3401
-                                                                                                               :fi 3402
-                                                                                                               :default 3400}
+                                                                                                               :fi 3402}
                                                                                        :license/attachment-filename {:en "en filename"
-                                                                                                                     :fi "fi filename"
-                                                                                                                     :default "non-localized filename"}
+                                                                                                                     :fi "fi filename"}
                                                                                        :license/enabled true
                                                                                        :license/archived false})})]
                     (is (= expected-application (apply-events events)))))
@@ -537,14 +514,11 @@
                                                                                           {:license/id 34
                                                                                            :license/type :attachment
                                                                                            :license/title {:en "en title"
-                                                                                                           :fi "fi title"
-                                                                                                           :default "non-localized title"}
+                                                                                                           :fi "fi title"}
                                                                                            :license/attachment-id {:en 3401
-                                                                                                                   :fi 3402
-                                                                                                                   :default 3400}
+                                                                                                                   :fi 3402}
                                                                                            :license/attachment-filename {:en "en filename"
-                                                                                                                         :fi "fi filename"
-                                                                                                                         :default "non-localized filename"}
+                                                                                                                         :fi "fi filename"}
                                                                                            :license/enabled true
                                                                                            :license/archived false})})]
                         (is (= expected-application (apply-events events)))))
@@ -564,14 +538,11 @@
                                                                                      {:license/id 33
                                                                                       :license/type :attachment
                                                                                       :license/title {:en "en title"
-                                                                                                      :fi "fi title"
-                                                                                                      :default "non-localized title"}
+                                                                                                      :fi "fi title"}
                                                                                       :license/attachment-id {:en 3301
-                                                                                                              :fi 3302
-                                                                                                              :default 3300}
+                                                                                                              :fi 3302}
                                                                                       :license/attachment-filename {:en "en filename"
-                                                                                                                    :fi "fi filename"
-                                                                                                                    :default "non-localized filename"}
+                                                                                                                    :fi "fi filename"}
                                                                                       :license/enabled true
                                                                                       :license/archived false})})]
                         (is (= expected-application (apply-events events)))
@@ -632,14 +603,11 @@
                                                                                                   {:license/id 34
                                                                                                    :license/type :attachment
                                                                                                    :license/title {:en "en title"
-                                                                                                                   :fi "fi title"
-                                                                                                                   :default "non-localized title"}
+                                                                                                                   :fi "fi title"}
                                                                                                    :license/attachment-id {:en 3401
-                                                                                                                           :fi 3402
-                                                                                                                           :default 3400}
+                                                                                                                           :fi 3402}
                                                                                                    :license/attachment-filename {:en "en filename"
-                                                                                                                                 :fi "fi filename"
-                                                                                                                                 :default "non-localized filename"}
+                                                                                                                                 :fi "fi filename"}
                                                                                                    :license/enabled true
                                                                                                    :license/archived false})})]
                                 (is (= expected-application (apply-events events)))))
diff --git a/test/clj/rems/db/test_licenses.clj b/test/clj/rems/db/test_licenses.clj
index deb805521..0f9d82ff7 100644
--- a/test/clj/rems/db/test_licenses.clj
+++ b/test/clj/rems/db/test_licenses.clj
@@ -10,18 +10,14 @@
                                                      {:licid 2 :langcode "fi" :title "fi title 2" :textcontent "fi content 2" :attachmentid 1}])]
     (is (= [{:id 1,
              :type "text",
-             :title "default title 1",
-             :textcontent "default content 1",
              :localizations {:en {:title "en title 1", :textcontent "en content 1", :attachment-id 1},
                              :fi {:title "fi title 1", :textcontent "fi content 1", :attachment-id 1}}}
             {:id 2,
              :type "link",
-             :title "default title 2",
-             :textcontent "default content 2",
              :localizations {:fi {:title "fi title 2", :textcontent "fi content 2", :attachment-id 1}}}]
            (#'rems.db.licenses/localize-licenses
-            [{:id 1 :type "text" :title "default title 1" :textcontent "default content 1"}
-             {:id 2 :type "link" :title "default title 2" :textcontent "default content 2"}])))))
+            [{:id 1 :type "text"}
+             {:id 2 :type "link"}])))))
 
 (deftest test-get-all-licenses
   (with-redefs [db/get-license-localizations (constantly [])
diff --git a/test/cljs/rems/administration/test_create_license.cljs b/test/cljs/rems/administration/test_create_license.cljs
index 89ec3ca68..6d78cceae 100644
--- a/test/cljs/rems/administration/test_create_license.cljs
+++ b/test/cljs/rems/administration/test_create_license.cljs
@@ -28,13 +28,9 @@
                                    :text "fi text"
                                    :attachment-filename "something_fi.pdf"
                                    :attachment-id 2}}}
-        default-language :en
         languages [:en :fi]]
     (testing "linked license"
-      (is (= {:title "en title"
-              :licensetype "link"
-              :textcontent "en link"
-              :attachment-id 1
+      (is (= {:licensetype "link"
               :localizations {:en {:title "en title"
                                    :textcontent "en link"
                                    :attachment-id 1}
@@ -42,13 +38,9 @@
                                    :textcontent "fi link"
                                    :attachment-id 2}}}
              (build-request (assoc-in form [:licensetype] "link")
-                            default-language
                             languages))))
     (testing "inline license"
-      (is (= {:title "en title"
-              :licensetype "text"
-              :textcontent "en text"
-              :attachment-id 1
+      (is (= {:licensetype "text"
               :localizations {:en {:title "en title"
                                    :textcontent "en text"
                                    :attachment-id 1}
@@ -56,14 +48,10 @@
                                    :textcontent "fi text"
                                    :attachment-id 2}}}
              (build-request (assoc-in form [:licensetype] "text")
-                            default-language
                             languages))))
 
     (testing "attachment license"
-      (is (= {:title "en title"
-              :licensetype "attachment"
-              :textcontent "something.pdf"
-              :attachment-id 1
+      (is (= {:licensetype "attachment"
               :localizations {:en {:title "en title"
                                    :textcontent "something.pdf"
                                    :attachment-id 1}
@@ -71,27 +59,20 @@
                                    :textcontent "something_fi.pdf"
                                    :attachment-id 2}}}
              (build-request (assoc-in form [:licensetype] "attachment")
-                            default-language
                             languages))))
     (testing "missing license type"
       (is (nil? (build-request (assoc-in form [:licensetype] nil)
-                               default-language
                                languages))))
     (testing "missing title"
       (is (nil? (build-request (assoc-in form [:localizations :en :title] "")
-                               default-language
                                languages)))
       (is (nil? (build-request (assoc-in form [:localizations :fi :title] "")
-                               default-language
                                languages))))
     (testing "missing license"
       (is (nil? (build-request (assoc-in form [:localizations :en :link] "")
-                               default-language
                                languages)))
       (is (nil? (build-request (assoc-in form [:localizations :fi :link] "")
-                               default-language
                                languages))))
     (testing "missing language"
       (is (nil? (build-request (update-in form [:localizations] dissoc :fi)
-                               default-language
                                languages))))))