Skip to content

#123 Implement display of row_number parameter for child tasks #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions project_template/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class OwnedLandTableEntry(CommonInfo):
taxable_value_currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
attainment_type = models.CharField("Modul de dobandire", max_length=32, choices=AttainmentType.return_as_iterable(), blank=True)
observations = models.CharField("Observatii", max_length=256, blank=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Cladiri - row numbers
Expand All @@ -161,6 +162,7 @@ class OwnedBuildingsTableEntry(CommonInfo):
taxable_value_currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
attainment_type = models.CharField("Modul de dobandire", max_length=32, choices=AttainmentType.return_as_iterable(), blank=True)
observations = models.CharField("Observatii", max_length=256, blank=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Bunuri Mobile - row numbers
Expand All @@ -178,6 +180,7 @@ class OwnedAutomobileTableEntry(models.Model):
no_owned = models.PositiveSmallIntegerField("Numar de bucati")
fabrication_year = models.IntegerField("Anul de fabricatie")
attainment_type = models.CharField("Modul de dobandire", max_length=32, choices=AttainmentType.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Bunuri Imobile - row numbers
Expand All @@ -194,6 +197,7 @@ class OwnedJewelryTableEntry(models.Model):
acquisition_year = models.IntegerField("Anul dobandirii")
goods_value = models.IntegerField("Suma")
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Bunuri Mobile Instrainate, Valoare peste 3000EUR - row numbers
Expand All @@ -212,6 +216,7 @@ class OwnedExtraValuableTableEntry(CommonInfo):
goods_separation_type = models.CharField("Forma instrainarii", max_length=64, choices=GoodsSeparationType.return_as_iterable())
value = models.IntegerField("Valoare")
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Conturi - row numbers
Expand All @@ -229,6 +234,7 @@ class OwnedBankAccountsTableEntry(models.Model):
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
opening_year = models.IntegerField("Deschis in anul")
account_balance = models.DecimalField("Soldul", decimal_places=2, max_digits=10)
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Plasamente, Investitii - row numbers
Expand All @@ -249,6 +255,7 @@ class OwnedInvestmentsOver5KTableEntry(models.Model):
share_ratio = models.DecimalField("Cota de participare", max_digits=5, decimal_places=2, null=True, blank=True, validators=[validate_percentage])
total_value = models.FloatField("Valoare totala la zi")
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Alte active - row numbers
Expand All @@ -264,6 +271,7 @@ class OtherActivesTableEntry(models.Model):
active_type = models.CharField("Tipul activului", max_length=128)
active_value = models.FloatField("Valoarea activului")
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Datorii - row numbers
Expand All @@ -283,6 +291,7 @@ class OwnedDebtsTableEntry(models.Model):
due_date = models.IntegerField("Scadent la")
value = models.FloatField("Valoare")
currency = models.CharField("Valuta", max_length=16, choices=Currency.return_as_iterable())
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Cadouri Servicii - row number
Expand All @@ -295,6 +304,7 @@ class OwnedGoodsOrServicesTable(models.Model):
# Tabel Cadouri Servicii - actual row information
class OwnedGoodsOrServicesTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedGoodsOrServicesTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


Expand All @@ -308,6 +318,7 @@ class OwnedIncomeFromSalariesTable(models.Model):
# Tabel Venituri salarii - actual row information
class OwnedIncomeFromSalariesTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromSalariesTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


Expand All @@ -321,9 +332,9 @@ class OwnedIncomeFromIndependentActivitiesTable(models.Model):
# Tabel Venituri activitati independente - actual row information
class OwnedIncomeFromIndependentActivitiesTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromIndependentActivitiesTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


# Tabel Venituri cedarea folosintei bunurilor - row number
class OwnedIncomeFromDeferredUseOfGoodsTable(models.Model):
__full_name = DECLARATION_TABLES['deferred_use']
Expand All @@ -334,9 +345,9 @@ class OwnedIncomeFromDeferredUseOfGoodsTable(models.Model):
# Tabel Venituri cedarea folosintei bunurilor - actual row information
class OwnedIncomeFromDeferredUseOfGoodsTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromDeferredUseOfGoodsTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


# Tabel Venituri investitii - row number
class OwnedIncomeFromInvestmentsTable(models.Model):
__full_name = DECLARATION_TABLES['income_investments']
Expand All @@ -347,9 +358,9 @@ class OwnedIncomeFromInvestmentsTable(models.Model):
# Tabel Venituri investitii - actual row information
class OwnedIncomeFromInvestmentsTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromInvestmentsTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


# Tabel Venituri pensii - row number
class OwnedIncomeFromPensionsTable(models.Model):
__full_name = DECLARATION_TABLES['pensions']
Expand All @@ -362,6 +373,7 @@ class OwnedIncomeFromPensionsTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromPensionsTable, on_delete=models.CASCADE, null=True)
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)
ex_position = models.CharField("Pozitia detinuta", max_length=128)
row_number = models.IntegerField("Numarul randului introdus din tabel")


# Tabel Venituri activitati agricole - row number
Expand All @@ -374,10 +386,10 @@ class OwnedIncomeFromAgriculturalActivitiesTable(models.Model):
# Tabel Venituri activitati agricole - actual row information
class OwnedIncomeFromAgriculturalActivitiesTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromAgriculturalActivitiesTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)
holder_type = models.CharField("Tipul detinatorului", max_length=120, choices=HolderType.return_as_iterable())


# Tabel Venituri premii jocuri noroc - row numbers
class OwnedIncomeFromGamblingTable(models.Model):
__full_name = DECLARATION_TABLES['gambling']
Expand All @@ -388,9 +400,9 @@ class OwnedIncomeFromGamblingTable(models.Model):
# Tabel Venituri premii jocuri noroc - actual row information
class OwnedIncomeFromGamblingTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromGamblingTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)


# Tabel Venituri din alte surse - row numbers
class OwnedIncomeFromOtherSourcesTable(models.Model):
__full_name = DECLARATION_TABLES['other_sources']
Expand All @@ -401,4 +413,5 @@ class OwnedIncomeFromOtherSourcesTable(models.Model):
# Tabel Venituri din alte surse - actual row information
class OwnedIncomeFromOtherSourcesTableEntry(CommonIncomeFields):
table = models.ForeignKey(OwnedIncomeFromOtherSourcesTable, on_delete=models.CASCADE, null=True)
row_number = models.IntegerField("Numarul randului introdus din tabel")
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)
4 changes: 3 additions & 1 deletion project_template/task_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class DigitalizationTask(AbstractTask):

def create_new_task(self, task, info):
from moonsheep.register import base_task
for k in info:
setattr(task, k, info[k])
base_task.register(task)

def create_mocked_task(self, task_data):
Expand All @@ -38,5 +40,5 @@ def save_verified_data(self, verified_data):
def after_save(self, verified_data):
# Create a new task for each table, asking the user to transcribe the number of rows
number_rows = int(verified_data['count'])
for row_number in list(range(1, number_rows)):
for row_number in range(1, number_rows + 1):
self.create_new_task(self.child_class, {'row_number': row_number})
48 changes: 33 additions & 15 deletions project_template/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def save_verified_data(self, verified_data):
taxable_value=verified_data['taxable_value'],
taxable_value_currency=verified_data['taxable_value_currency'],
attainment_type=verified_data['attainment_type'],
observations=verified_data.get('observations', '')
observations=verified_data.get('observations', ''),
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand All @@ -74,6 +75,7 @@ def save_verified_data(self, verified_data):
no_owned=verified_data['num_of_automobiles'],
fabrication_year=verified_data['year_of_manufacture'],
attainment_type=verified_data['attainment_type'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand All @@ -94,6 +96,7 @@ def save_verified_data(self, verified_data):
currency=verified_data['currency'],
opening_year=verified_data['account_start_date'],
account_balance=verified_data['balance'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -123,6 +126,7 @@ def save_verified_data(self, verified_data):
commune=verified_data['commune'],
service=verified_data['offered_service'],
annual_income=verified_data['income_amount'],
row_number=self.row_number if hasattr(self, 'row_number') else -1,
currency=verified_data['currency']
)

Expand All @@ -149,7 +153,8 @@ def save_verified_data(self, verified_data):
acquirement_year=verified_data['loan_start_year'],
due_date=verified_data['loan_maturity'],
value=verified_data['loan_amount'],
currency=verified_data['currency']
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)
elif verified_data['institution']:
owned_debts, created = models.OwnedDebtsTableEntry.objects.get_or_create(
Expand All @@ -158,8 +163,9 @@ def save_verified_data(self, verified_data):
acquirement_year=verified_data['loan_start_year'],
due_date=verified_data['loan_maturity'],
value=verified_data['loan_amount'],
currency=verified_data['currency']
)
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


class TaskOwnedDebtsTable(CountTableRowsTask):
Expand Down Expand Up @@ -188,7 +194,8 @@ def save_verified_data(self, verified_data):
service=verified_data['offered_service'],
ex_position=verified_data['position'],
annual_income=verified_data['income_amount'],
currency=verified_data['currency'])
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1)


class TaskOwnedIncomeFromPensionsTable(CountTableRowsTask):
Expand Down Expand Up @@ -218,6 +225,7 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand All @@ -233,8 +241,8 @@ class TaskOwnedInvestmentsOver5KRowEntry(DigitalizationTask):

def save_verified_data(self, verified_data):
loan_beneficiary, created = models.Person.objects.get_or_create(
name=verified_data['name'],
surname=verified_data['surname']
name=verified_data['beneficiary_name'],
surname=verified_data['beneficiary_surname']
)

owned_investments_over_5k, created = models.OwnedInvestmentsOver5KTableEntry.objects.get_or_create(
Expand All @@ -245,7 +253,8 @@ def save_verified_data(self, verified_data):
number_of_stocks=verified_data['number_of_stocks'],
share_ratio=verified_data['share_ratio'],
total_value=verified_data['total_value'],
currency=verified_data['currency']
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -276,7 +285,8 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
)
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


class TaskOwnedIncomeFromOtherSourcesTable(CountTableRowsTask):
Expand All @@ -294,7 +304,8 @@ def save_verified_data(self, verified_data):
summary_description=verified_data['description'],
acquisition_year=verified_data['ownership_start_year'],
goods_value=verified_data['estimated_value'],
currency=verified_data['currency'])
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1)


class TaskOwnedJewelryTable(CountTableRowsTask):
Expand Down Expand Up @@ -322,7 +333,8 @@ def save_verified_data(self, verified_data):
estrangement_date=verified_data['estranged_date'],
goods_separation_type=verified_data['goods_separation_type'],
value=verified_data['estimated_value'],
currency=verified_data['currency']
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -353,6 +365,7 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -383,6 +396,7 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -413,6 +427,7 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -443,6 +458,7 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
annual_income=verified_data['annual_income'],
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


Expand Down Expand Up @@ -474,17 +490,18 @@ def save_verified_data(self, verified_data):
taxable_value=verified_data['taxable_value'],
taxable_value_currency=verified_data['taxable_value_currency'],
attainment_type=verified_data['attainment_type'],
observations=verified_data.get('observations', '')
observations=verified_data.get('observations', ''),
row_number=self.row_number if hasattr(self, 'row_number') else -1
)


@register()
class TaskOwnedBuildingsTable(CountTableRowsTask):
task_form = forms.TranscribeOwnedBuildingsTable
storage_model = models.OwnedBuildingsTable
child_class = TaskOwnedBuildingsRowEntry


@register()
class TaskOwnedIncomeFromInvestmentsRowEntry(DigitalizationTask):
task_form = forms.TranscribeOwnedIncomeFromInvestmentsRowEntry
template_name = "tasks/owned_investments.html"
Expand All @@ -504,11 +521,12 @@ def save_verified_data(self, verified_data):
service=verified_data['service'],
source_of_goods=verified_data['source_of_goods'],
annual_income=verified_data['income_amount'],
currency=verified_data['currency']
currency=verified_data['currency'],
row_number=self.row_number if hasattr(self, 'row_number') else -1
)



@register()
class TaskOwnedIncomeFromInvestmentsTable(CountTableRowsTask):
task_form = forms.TranscribeOwnedIncomeFromInvestmentsTable
storage_model = models.OwnedIncomeFromInvestmentsTable
Expand Down
2 changes: 2 additions & 0 deletions project_template/templates/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<div class="row-fluid">
{# Provide additional context for non-native speakers #}
{% if "en" in request.LANGUAGE_CODE %}
{% with row_num=task.row_number %}
{% block explanation %}{% endblock %}
{% endwith %}
{% endif %}
{# Forms incoming! #}
<div class="col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block explanation %}
<div class = "row-fluid">
<p>Va rugam introduceti informatiile de pe randul {{nr_rand}} completat din tabelul "Bunuri Imobile - Cladiri".</p>
<p>Va rugam introduceti informatiile de pe randul {{row_num}} completat din tabelul "Bunuri Imobile - Cladiri".</p>

</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block explanation %}
<div class = "row-fluid">
<p>Va rugam introduceti informatiile de pe randul {{nr_rand}} completat din tabelul VI. "Cadouri, servicii".</p>
<p>Va rugam introduceti informatiile de pe randul {{row_num}} completat din tabelul VI. "Cadouri, servicii".</p>

</div>
{% endblock %}
Loading