aboutsummaryrefslogtreecommitdiff
path: root/web/webqtl/dataSharing/SharingListDataSetPage.py
blob: ec90f5f37a8f84cf2ed265bd47bd9b7afa5412d0 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# This program is available from Source Forge: at GeneNetwork Project
# (sourceforge.net/projects/genenetwork/).
#
# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
#
#
#
# This module is used by GeneNetwork project (www.genenetwork.org)
#
# Created by GeneNetwork Core Team 2010/08/10
#
# Last updated by GeneNetwork Core Team 2010/10/20

from htmlgen import HTMLgen2 as HT
from base import webqtlConfig

from base.templatePage import templatePage


#########################################
#      Sharing List DataSet Page
#########################################
class SharingListDataSetPage(templatePage):

    def __init__(self, fd=None):
        templatePage.__init__(self, fd)

        if not self.openMysql():
            return

        if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['admin']:
            pass
        else:
            heading = "Editing Info"
            detail = ["You don't have the permission to list the datasets"]
            self.error(heading=heading,detail=detail,error="Error")
            return


        TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee')

        query = """select GN_AccesionId, InfoPageTitle, Progreso from InfoFiles order by GN_AccesionId"""
        self.cursor.execute(query)
        result = self.cursor.fetchall()

        heading = HT.Paragraph('Dataset Table', Class="title")
		
        newrecord = HT.Href(text="New Record", url="/webqtl/main.py?FormID=sharinginfoadd")

        info = "Click the accession id to view the dataset info. Click the dataset name to edit the dataset info."
        
        datasetTable = HT.TableLite(border=0, cellpadding=0, cellspacing=0, Class="collap", width="100%")

        tableHeaderRow = HT.TR()
        tableHeaderRow.append(HT.TD("Accession Id", Class='fs14 fwb ffl b1 cw cbrb', align="center"))
        tableHeaderRow.append(HT.TD("Dataset name", Class='fs14 fwb ffl b1 cw cbrb', align="center"))
        tableHeaderRow.append(HT.TD("Progress", Class='fs14 fwb ffl b1 cw cbrb', align="center"))
        tableHeaderRow.append(HT.TD("Operation", Class='fs14 fwb ffl b1 cw cbrb', align="center"))
        datasetTable.append(tableHeaderRow)

        for one_row in result:
            Accession_Id, InfoPage_title, Progress = one_row
            datasetRow = HT.TR()
            datasetRow.append(HT.TD(HT.Href(text="GN%s" % Accession_Id, url="/webqtl/main.py?FormID=sharinginfo&GN_AccessionId=%s" % Accession_Id, Class='fs12 fwn'), Class="fs12 fwn b1 c222"))
            datasetRow.append(HT.TD(HT.Href(text="%s" % InfoPage_title, url="/webqtl/main.py?FormID=sharinginfo&GN_AccessionId=%s" % Accession_Id, Class='fs12 fwn'), Class="fs12 fwn b1 c222"))
            datasetRow.append(HT.TD("%s" % Progress, Class='fs12 fwn ffl b1 c222'))
            operation_edit = HT.Href(text="Edit", url="/webqtl/main.py?FormID=sharinginfoedit&GN_AccessionId=%s" % Accession_Id)
            operation_delete = HT.Href(text="Delete", onClick="deleteRecord(%s); return false;" % Accession_Id)
            operation = HT.TD(Class="fs12 fwn b1 c222", align="center")
            operation.append(operation_edit)
            operation.append("    ")
            operation.append(operation_delete)
            datasetRow.append(operation)
            datasetTable.append(datasetRow)

        TD_LR.append(heading, HT.P(), newrecord, HT.P(), info, HT.P(), datasetTable)
		
        js1 = """	<script language="javascript" type="text/javascript">
					function deleteRecord(id){
						question = confirm("Are you sure you want to delete the dataset info record (Accession Id="+id+")?")
						if (question != "0"){
							window.open("/webqtl/main.py?FormID=sharinginfodelete&GN_AccessionId="+id, "_self");
						}
					}
					</script>"""
        self.dict['js1'] = js1
        self.dict['body'] =  str(TD_LR)