Coverage for crateweb/nlp_classification/tables.py: 100%
59 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-27 10:34 -0500
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-27 10:34 -0500
1"""
2crate_anon/crateweb/nlp_classification/tables.py
4===============================================================================
6 Copyright (C) 2015, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CRATE.
11 CRATE is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 CRATE is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with CRATE. If not, see <https://www.gnu.org/licenses/>.
24===============================================================================
26CRATE NLP classification tables.
28"""
30from crate_anon.crateweb.nlp_classification.models import (
31 Assignment,
32 Option,
33 Question,
34 SampleSpec,
35 TableDefinition,
36 Task,
37 UserAnswer,
38)
40import django_tables2 as tables
43class NlpClassificationTable(tables.Table):
44 name = tables.Column()
45 dest_table = tables.Column()
46 dest_column = tables.Column()
47 sample_spec = tables.Column()
48 classified = tables.Column()
49 precision = tables.Column()
50 recall = tables.Column()
53class UserAnswerTable(tables.Table):
54 class Meta:
55 model = UserAnswer
57 user = tables.Column()
58 source_record = tables.Column()
59 decision = tables.Column()
60 rate = tables.LinkColumn(
61 "nlp_classification_user_answer", text="Rate", args=[tables.A("pk")]
62 )
65class UserAssignmentTable(tables.Table):
66 class Meta:
67 model = Assignment
69 task = tables.Column()
70 sample_spec = tables.Column()
71 view = tables.LinkColumn(
72 "nlp_classification_user_assignment",
73 text="View",
74 args=[tables.A("pk")],
75 )
78class AdminAssignmentTable(tables.Table):
79 class Meta:
80 model = Assignment
82 task = tables.LinkColumn(
83 "nlp_classification_admin_assignment_edit",
84 args=[tables.A("pk")],
85 )
86 sample_spec = tables.LinkColumn(
87 "nlp_classification_admin_assignment_edit",
88 args=[tables.A("pk")],
89 )
90 user = tables.LinkColumn(
91 "nlp_classification_admin_assignment_edit",
92 args=[tables.A("pk")],
93 )
96class FieldTable(tables.Table):
97 name = tables.Column()
98 value = tables.Column()
101class OptionTable(tables.Table):
102 class Meta:
103 model = Option
105 description = tables.LinkColumn(
106 "nlp_classification_admin_option_edit", args=[tables.A("pk")]
107 )
110class QuestionTable(tables.Table):
111 class Meta:
112 model = Question
114 title = tables.LinkColumn(
115 "nlp_classification_admin_question_edit", args=[tables.A("pk")]
116 )
117 task = tables.Column()
120class SampleSpecTable(tables.Table):
121 class Meta:
122 model = SampleSpec
124 source_column = tables.LinkColumn(
125 "nlp_classification_admin_sample_spec_edit", args=[tables.A("pk")]
126 )
127 nlp_table_definition = tables.LinkColumn(
128 "nlp_classification_admin_sample_spec_edit", args=[tables.A("pk")]
129 )
130 search_term = tables.LinkColumn(
131 "nlp_classification_admin_sample_spec_edit", args=[tables.A("pk")]
132 )
133 size = tables.LinkColumn(
134 "nlp_classification_admin_sample_spec_edit", args=[tables.A("pk")]
135 )
136 seed = tables.LinkColumn(
137 "nlp_classification_admin_sample_spec_edit", args=[tables.A("pk")]
138 )
141class TableDefinitionTable(tables.Table):
142 class Meta:
143 model = TableDefinition
145 db_connection_name = tables.LinkColumn(
146 "nlp_classification_admin_table_definition_edit", args=[tables.A("pk")]
147 )
148 table_name = tables.LinkColumn(
149 "nlp_classification_admin_table_definition_edit", args=[tables.A("pk")]
150 )
151 pk_column_name = tables.LinkColumn(
152 "nlp_classification_admin_table_definition_edit", args=[tables.A("pk")]
153 )
156class TaskTable(tables.Table):
157 class Meta:
158 model = Task
160 name = tables.LinkColumn(
161 "nlp_classification_admin_task_edit", args=[tables.A("pk")]
162 )