예제 #1
0
def change_activity_id(old_id, new_id):
    #
    activity = Activity.objects.get(pk=old_id)
    activity.id = new_id
    activity.save()
    #
    new_activity = activity
    old_activity = Activity.objects.get(pk=old_id)
    #
    print new_activity
    #
    change_related_model_parent_activity(new_activity,
                                         old_activity.reporting_organisations)
    change_one_to_one_parent_activity(new_activity, old_activity.title)
    change_related_model_parent_activity(new_activity,
                                         old_activity.description_set)
    change_related_model_parent_activity(
        new_activity, old_activity.participating_organisations)
    change_related_model_parent_activity(new_activity,
                                         old_activity.activitydate_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.contactinfo_set)
    change_m2m_parent_activity(new_activity,
                               old_activity.activityrecipientcountry_set)
    change_m2m_parent_activity(new_activity,
                               old_activity.activityrecipientregion_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.location_set)
    change_m2m_parent_activity(new_activity, old_activity.activitysector_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.humanitarianscope_set)
    change_m2m_parent_activity(new_activity,
                               old_activity.activitypolicymarker_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.planneddisbursement_set)
    change_related_model_parent_activity(new_activity, old_activity.budget_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.transaction_set)
    change_related_model_parent_activity(new_activity,
                                         old_activity.documentlink_set)
    change_related_activity_parent_activity(new_activity,
                                            old_activity.relatedactivity_set)
    change_related_model_parent_activity(new_activity, old_activity.result_set)
    #
    post_save.set_related_activities(new_activity)
    post_save.set_participating_organisation_activity_id(
        new_activity.participating_organisations)
    post_save.set_transaction_provider_receiver_activity(new_activity)
    post_save.set_derived_activity_dates(new_activity)
    post_save.set_activity_aggregations(new_activity)
    post_save.update_activity_search_index(new_activity)
    post_save.set_country_region_transaction(new_activity)
    post_save.set_sector_transaction(new_activity)
    post_save.set_sector_budget(new_activity)
    old_activity.delete()
예제 #2
0
    def save_related(self, request, form, formsets, change):
        super(TransactionAdmin, self).save_related(request, form, formsets,
                                                   change)

        # remove old
        TransactionSector.objects.filter(
            transaction__activity=self.act).delete()
        TransactionRecipientCountry.objects.filter(
            transaction__activity=self.act).delete()
        TransactionRecipientRegion.objects.filter(
            transaction__activity=self.act).delete()

        # add new
        post_save.set_transaction_provider_receiver_activity(self.act)
        post_save.set_activity_aggregations(self.act)
        post_save.set_country_region_transaction(self.act)
        post_save.set_sector_transaction(self.act)
예제 #3
0
    def save_related(self, request, form, formsets, change):
        super(ActivityAdmin, self).save_related(request, form, formsets,
                                                change)
        post_save.set_derived_activity_dates(self.act)
        post_save.set_activity_aggregations(self.act)
        post_save.update_activity_search_index(self.act)

        # remove old
        BudgetSector.objects.filter(budget__activity=self.act).delete()
        TransactionSector.objects.filter(
            transaction__activity=self.act).delete()
        TransactionRecipientCountry.objects.filter(
            transaction__activity=self.act).delete()
        TransactionRecipientRegion.objects.filter(
            transaction__activity=self.act).delete()

        # add new
        post_save.set_country_region_transaction(self.act)
        post_save.set_sector_transaction(self.act)
        post_save.set_sector_budget(self.act)