The SIO2 project
  1. The SIO2 project
  2. SIO-2057

Creating a team in admin mode is causing an error if we add membership at the same time

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Current Version
    • Fix Version/s: None
    • Component/s: OIOIOI
    • Labels:
      None

      Description

      Just try to add a new team and add some members at the same time.
      The following error should occur:

        File "/home/rno/sio2/venv/local/lib/python2.7/site-packages/django/forms/models.py", line 411, in validate_unique
          self.instance.validate_unique(exclude=exclude)
        File "/home/rno/sio2/oioioi/oioioi/teams/models.py", line 45, in validate_unique
          team__contest=self.team.contest) \
        File "/home/rno/sio2/venv/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py", line 179, in __get__
          "%s has no %s." % (self.field.model.__name__, self.field.name)
      RelatedObjectDoesNotExist: Team has no contest.

      When we first add a team and then try to add its members, it works.

        Activity

        Hide
        Artur Puzio added a comment - - edited
        I confirm the issue.
        Show
        Artur Puzio added a comment - - edited I confirm the issue.
        Hide
        Gerrit Gerrit added a comment -
        Change oioioi~master~Ibc94af0778963aa5313eb759d8432eb9fc7863f2, patchset 1
        https://gerrit.sio2project.mimuw.edu.pl/3095

        SIO-2057 Fix adding Team members on team creation

        We set team.contest in save_form instead of save_mode. This makes it set
        earlier in the admin form saving process, so team.contest value is set
        when TeamMembership.validate_unique is called.

        Change-Id: Ibc94af0778963aa5313eb759d8432eb9fc7863f2
        Show
        Gerrit Gerrit added a comment - Change oioioi~master~Ibc94af0778963aa5313eb759d8432eb9fc7863f2, patchset 1 https://gerrit.sio2project.mimuw.edu.pl/3095 SIO-2057 Fix adding Team members on team creation We set team.contest in save_form instead of save_mode. This makes it set earlier in the admin form saving process, so team.contest value is set when TeamMembership.validate_unique is called. Change-Id: Ibc94af0778963aa5313eb759d8432eb9fc7863f2

          People

          • Assignee:
            Szymon AcedaƄski
            Reporter:
            Bartosz Kostka
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: