Skip to content
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

Introduce Access Card management #3506

Merged
merged 12 commits into from
Jan 16, 2020

Conversation

lukaszkarykowski
Copy link
Contributor

No description provided.

blank=True,
help_text=_('Optional notes')
)
user = models.ForeignKey(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add on_delete attribute. I recommend you on_delete=models.SET_NULL in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any limits? Can every user have an unlimited number of cards?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, User can have any number of cards.

RalphUser,
null=True,
blank=True,
related_name='used_access_cards',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any usage of backward relation. Please consider + if you don't need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

RalphUser,
null=True,
blank=True,
related_name='owned_access_cards',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

blank=True,
help_text=_('Optional notes')
)
user = models.ForeignKey(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any limits? Can every user have an unlimited number of cards?

ar4s
ar4s previously approved these changes Jan 16, 2020
)

def __str__(self):
return _('Access Card: {}').format(self.visual_number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better override the default autocomplete queryset in order to filter out liquidated cards.

    def get_autocomplete_queryset(cls):
        return cls._default_manager.exclude(
            status=AccessCardStatus.liquidated.id
        )```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

'visual_number':'654321',
'system_number':'F9876DSGV',
'notes':'test note',
'issue_date':'2020-01-02'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

region is a required field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

class AccessCardFactory(DjangoModelFactory):
visual_number = factory.Sequence(lambda n: '000000000000{}'.format(n))
system_number = factory.Sequence(lambda n: '000000000000{}'.format(n))
status = AccessCardStatus.new
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

region is a required field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

)
self.assertEqual(
response_data['owner']['username'],
access_card.owner.username
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check the region as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@coveralls
Copy link

coveralls commented Jan 16, 2020

Coverage Status

Coverage increased (+0.04%) to 84.543% when pulling 989dce3 on lukaszkarykowski:Access_cards/models into 8d4fc61 on allegro:ng.

Copy link
Contributor

@romcheg romcheg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@romcheg romcheg merged commit 720c12c into allegro:ng Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants