Skip to content

Commit

Permalink
Adds endcheck and prestep functions to join table lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
SrNetoChan committed Nov 13, 2017
1 parent 3bd88f5 commit b5542d0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* In the **Layers Panel**, right-click the *Blocks 2010* layer and
select **Open Attribute Table**
select **Properties**

![open_layer_properties](open_layer_properties.png)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
* In the **Layers Properties - Blocks 2010**, click the **Join** tab.

![open_joins_tab](open_joins_tab.png)

* There are no joins yet for this layer. Click the **Add Join** button
to create one.

Expand Down
25 changes: 25 additions & 0 deletions vector_layers_attributes/Join_table_to_vector_layer/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from lessons.utils import layerFromName

# Functions

# EndCheck Function

def fieldExists(layername, string):
"""
Check if a layer has a field which name contains the specified string
The layer should be of the vector type and be loaded into project.
:param layername: Layer's name as visible in the layers panel
:param string: string of text
:return: Boolean
"""

layer = layerFromName(layername)
if layer is None:
return False

for field in layer.pendingFields():
if string in field.name():
return True

return False
21 changes: 21 additions & 0 deletions vector_layers_attributes/Join_table_to_vector_layer/lesson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,28 @@ lesson:
name: Inspect attribute of tabular layer
- description: 04_open_layer_properties.md
name: Open layer properties

prestep:
name: utils.unmodalWidget
params:
- QgsVectorLayerPropertiesBase
- 300
- 1000

- description: 05_add_vector_join.md
name: Add vector join

prestep:
name: utils.unmodalWidget
params:
- QgsJoinDialog
- 300
- 1000

endcheck:
name: fieldExists
params:
- Blocks 2010
- TOTAL_POP
- description: 06_inspect_polygon_layer_attributes_(again).md
name: Inspect polygon layer attributes (again)
Binary file not shown.

0 comments on commit b5542d0

Please sign in to comment.