kopia lustrzana https://github.com/simonw/datasette
				
				
				
			No longer include database hash in hyperlinks
It was making the unit tests unreliable. Also we do not do that for foreign key links.pull/178/head
							rodzic
							
								
									7db790fbf9
								
							
						
					
					
						commit
						ae94006809
					
				| 
						 | 
				
			
			@ -419,7 +419,6 @@ class RowTableShared(BaseView):
 | 
			
		|||
    async def display_columns_and_rows(self, database, table, description, rows, link_column=False, expand_foreign_keys=True):
 | 
			
		||||
        "Returns columns, rows for specified table - including fancy foreign key treatment"
 | 
			
		||||
        info = self.ds.inspect()[database]
 | 
			
		||||
        database_hash = info['hash'][:HASH_LENGTH]
 | 
			
		||||
        columns = [r[0] for r in description]
 | 
			
		||||
        tables = info['tables']
 | 
			
		||||
        table_info = tables.get(table) or {}
 | 
			
		||||
| 
						 | 
				
			
			@ -459,9 +458,8 @@ class RowTableShared(BaseView):
 | 
			
		|||
                cells.append({
 | 
			
		||||
                    'column': 'Link',
 | 
			
		||||
                    'value': jinja2.Markup(
 | 
			
		||||
                        '<a href="/{database}-{database_hash}/{table}/{flat_pks}">{flat_pks}</a>'.format(
 | 
			
		||||
                        '<a href="/{database}/{table}/{flat_pks}">{flat_pks}</a>'.format(
 | 
			
		||||
                            database=database,
 | 
			
		||||
                            database_hash=database_hash,
 | 
			
		||||
                            table=urllib.parse.quote_plus(table),
 | 
			
		||||
                            flat_pks=path_from_row_pks(row, pks, not pks),
 | 
			
		||||
                        )
 | 
			
		||||
| 
						 | 
				
			
			@ -471,9 +469,8 @@ class RowTableShared(BaseView):
 | 
			
		|||
                if (column, value) in expanded:
 | 
			
		||||
                    other_table, label = expanded[(column, value)]
 | 
			
		||||
                    display_value = jinja2.Markup(
 | 
			
		||||
                        '<a href="/{database}-{database_hash}/{table}/{id}">{label}</a> <em>{id}</em>'.format(
 | 
			
		||||
                        '<a href="/{database}/{table}/{id}">{label}</a> <em>{id}</em>'.format(
 | 
			
		||||
                            database=database,
 | 
			
		||||
                            database_hash=database_hash,
 | 
			
		||||
                            table=urllib.parse.quote_plus(other_table),
 | 
			
		||||
                            id=str(jinja2.escape(value)),
 | 
			
		||||
                            label=str(jinja2.escape(label)),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -448,15 +448,15 @@ def test_table_html_simple_primary_key(app_client):
 | 
			
		|||
    ] == [th.string for th in table.select('thead th')]
 | 
			
		||||
    assert [
 | 
			
		||||
        [
 | 
			
		||||
            '<td><a href="/test_tables-c0e2850/simple_primary_key/1">1</a></td>',
 | 
			
		||||
            '<td><a href="/test_tables/simple_primary_key/1">1</a></td>',
 | 
			
		||||
            '<td>1</td>',
 | 
			
		||||
            '<td>hello</td>'
 | 
			
		||||
        ], [
 | 
			
		||||
            '<td><a href="/test_tables-c0e2850/simple_primary_key/2">2</a></td>',
 | 
			
		||||
            '<td><a href="/test_tables/simple_primary_key/2">2</a></td>',
 | 
			
		||||
            '<td>2</td>',
 | 
			
		||||
            '<td>world</td>'
 | 
			
		||||
        ], [
 | 
			
		||||
            '<td><a href="/test_tables-c0e2850/simple_primary_key/3">3</a></td>',
 | 
			
		||||
            '<td><a href="/test_tables/simple_primary_key/3">3</a></td>',
 | 
			
		||||
            '<td>3</td>',
 | 
			
		||||
            '<td></td>'
 | 
			
		||||
        ]
 | 
			
		||||
| 
						 | 
				
			
			@ -485,7 +485,7 @@ def test_table_html_no_primary_key(app_client):
 | 
			
		|||
    ] == [th.string for th in table.select('thead th')]
 | 
			
		||||
    expected = [
 | 
			
		||||
        [
 | 
			
		||||
            '<td><a href="/test_tables-c0e2850/no_primary_key/{}">{}</a></td>'.format(i, i),
 | 
			
		||||
            '<td><a href="/test_tables/no_primary_key/{}">{}</a></td>'.format(i, i),
 | 
			
		||||
            '<td>{}</td>'.format(i),
 | 
			
		||||
            '<td>{}</td>'.format(i),
 | 
			
		||||
            '<td>a{}</td>'.format(i),
 | 
			
		||||
| 
						 | 
				
			
			@ -522,7 +522,7 @@ def test_table_html_compound_primary_key(app_client):
 | 
			
		|||
    ] == [th.string for th in table.select('thead th')]
 | 
			
		||||
    expected = [
 | 
			
		||||
        [
 | 
			
		||||
            '<td><a href="/test_tables-c0e2850/compound_primary_key/a,b">a,b</a></td>',
 | 
			
		||||
            '<td><a href="/test_tables/compound_primary_key/a,b">a,b</a></td>',
 | 
			
		||||
            '<td>a</td>',
 | 
			
		||||
            '<td>b</td>',
 | 
			
		||||
            '<td>c</td>',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue