-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Isort code in tests * Support offer files * Isort * Isort * Isort code in tests * Isort!! * Isort * Isort!! * Support new Tag model * Fix lint errors * Remove ValuesDict * Fix typos * Remove redundant assert * Add changelog entry * Isort * Add extra whitespace * isort * Don't comment code, move changes to unreleased * Remove redundant empty line * Lint
- Loading branch information
1 parent
40f7a15
commit c56c6c3
Showing
10 changed files
with
1,609 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from .core import InvisibleModelManager, Model, ModelManager | ||
|
||
|
||
class TagRelation(Model): | ||
""" | ||
This is a common model for (Offer|Affiliate|Advertiser)Tag objects. These objects just represent relation between | ||
tag and corresponding object. They are auxiliary objects, hence - no actions on them could be performed directly. | ||
""" | ||
|
||
|
||
class TagRelationManager(InvisibleModelManager): | ||
model = TagRelation | ||
model_aliases = ( | ||
'OffersTags', | ||
'AffiliatesTags', | ||
'AdvertisersTags', | ||
) | ||
|
||
|
||
class Tag(Model): | ||
generic_methods = ('update', 'delete') | ||
|
||
def add_to_offer(self, offer_id): | ||
return self._manager.add_to_offer(self.id, offer_id=offer_id) | ||
|
||
def add_to_affiliate(self, affiliate_id): | ||
return self._manager.add_to_affiliate(self.id, affiliate_id=affiliate_id) | ||
|
||
def add_to_advertiser(self, advertiser_id): | ||
return self._manager.add_to_advertiser(self.id, advertiser_id=advertiser_id) | ||
|
||
def remove_from_offer(self, offer_id): | ||
return self._manager.remove_from_offer(self.id, offer_id=offer_id) | ||
|
||
def remove_from_affiliate(self, affiliate_id): | ||
return self._manager.remove_from_affiliate(self.id, affiliate_id=affiliate_id) | ||
|
||
def remove_from_advertiser(self, advertiser_id): | ||
return self._manager.remove_from_advertiser(self.id, advertiser_id=advertiser_id) | ||
|
||
|
||
class TagManager(ModelManager): | ||
model = Tag | ||
name = 'tags' | ||
generic_methods = ( | ||
'find_by_id', | ||
'find_all', | ||
'delete', | ||
'update', | ||
'create', | ||
) | ||
|
||
def find_all_offer_tag_relations(self, **kwargs): | ||
return self._call('findAllOfferTagRelations', target_class='TagRelation', single_result=False, **kwargs) | ||
|
||
def find_all_affiliate_tag_relations(self, **kwargs): | ||
return self._call('findAllAffiliateTagRelations', target_class='TagRelation', single_result=False, **kwargs) | ||
|
||
def find_all_advertiser_tag_relations(self, **kwargs): | ||
return self._call('findAllAdvertiserTagRelations', target_class='TagRelation', single_result=False, **kwargs) | ||
|
||
def add_to_offer(self, tag_id, offer_id): | ||
return self._call('addToOffer', target_class='TagRelation', tag_id=tag_id, offer_id=offer_id) | ||
|
||
def add_to_affiliate(self, tag_id, affiliate_id): | ||
return self._call('addToAffiliate', target_class='TagRelation', tag_id=tag_id, affiliate_id=affiliate_id) | ||
|
||
def add_to_advertiser(self, tag_id, advertiser_id): | ||
return self._call('addToAdvertiser', target_class='TagRelation', tag_id=tag_id, advertiser_id=advertiser_id) | ||
|
||
def set_for_offer(self, tag_ids, offer_id): | ||
return self._call('setForOffer', target_class='TagRelation', tag_ids=tag_ids, offer_id=offer_id) | ||
|
||
def set_for_affiliate(self, tag_ids, affiliate_id): | ||
return self._call('setForAffiliate', target_class='TagRelation', tag_ids=tag_ids, affiliate_id=affiliate_id) | ||
|
||
def set_for_advertiser(self, tag_ids, advertiser_id): | ||
return self._call('setForAdvertiser', target_class='TagRelation', tag_ids=tag_ids, advertiser_id=advertiser_id) | ||
|
||
def remove_from_offer(self, tag_id, offer_id): | ||
return self._call('removeFromOffer', tag_id=tag_id, offer_id=offer_id) | ||
|
||
def remove_from_affiliate(self, tag_id, affiliate_id): | ||
return self._call('removeFromAffiliate', tag_id=tag_id, affiliate_id=affiliate_id) | ||
|
||
def remove_from_advertiser(self, tag_id, advertiser_id): | ||
return self._call('removeFromAdvertiser', tag_id=tag_id, advertiser_id=advertiser_id) | ||
|
||
def remove_from_advertiser_by_relational_id(self, id): | ||
return self._call('removeFromAdvertiserByRelationalId', id=id) | ||
|
||
def remove_from_offer_by_relational_id(self, id): | ||
return self._call('removeFromOfferByRelationalId', id=id) | ||
|
||
def remove_from_affiliate_by_relational_id(self, id): | ||
return self._call('removeFromAffiliateByRelationalId', id=id) |
Oops, something went wrong.