Example #1
0
def confirm_ship_mstone(request):
    """Intermediate page when shipping a milestone.

    Gathers all data to verify when shipping.
    Ends up in ship_mstone if everything is fine.
    Redirects to milestones() in case of trouble.
    """
    if not request.GET.get('ms'):
        raise Http404("ms must be supplied")
    mstone = get_object_or_404(Milestone, code=request.GET['ms'])
    if mstone.status != Milestone.OPEN:
        return HttpResponseRedirect(reverse('shipping.views.milestones'))
    statuses = flag_lists(appversions={'id': mstone.appver_id})
    pending_locs = []
    good = 0
    for (tree, loc), flags in statuses.iteritems():
        if 0 in flags:
            # pending
            pending_locs.append(loc)
        if 1 in flags:
            # good
            good += 1
    pending_locs.sort()
    return render_to_response('shipping/confirm-ship.html',
                              {'mstone': mstone,
                               'pending_locs': pending_locs,
                               'good': good,
                               'login_form_needs_reload': True,
                               'request': request,
                             },
                              context_instance=RequestContext(request))
Example #2
0
File: tests.py Project: stasm/elmo
 def test_getlist(self):
     """Test that the list returns the right flags."""
     flags = flag_lists(appversions={"code": "fx1.0"})
     eq_(flags, {("fx", "pl"): [0],
                  ("fx", "de"): [1],
                  ("fx", "fr"): [2],
                  ("fx", "da"): [1, 0]})
Example #3
0
 def test_getlist(self):
     """Test that the list returns the right flags."""
     flags = flag_lists(appversions={"code": "fx1.0"})
     # note that the flags below are [1, 0] (and not [0, 1])
     # which means the ACCEPTED comes *before* PENDING
     eq_(flags, {("fx", "pl"): [Action.PENDING],
                  ("fx", "de"): [Action.ACCEPTED],
                  ("fx", "fr"): [Action.REJECTED],
                  ("fx", "da"): [Action.ACCEPTED, Action.PENDING]})
Example #4
0
File: tests.py Project: stasm/elmo
 def test_getlist(self):
     """Test that the list returns the right flags."""
     flags = flag_lists(appversions={"code": "fx1.0"})
     eq_(
         flags, {
             ("fx", "pl"): [0],
             ("fx", "de"): [1],
             ("fx", "fr"): [2],
             ("fx", "da"): [1, 0]
         })
Example #5
0
File: status.py Project: stasm/elmo
 def data_for_avq(self, avq):
     apps = list(
         AppVersion.objects.filter(**avq).values_list('app',
                                                      flat=True).distinct())
     if len(apps) == 1:
         given_app = Application.objects.get(id=apps[0]).code
     else:
         given_app = None
     if apps:
         appvers = AppVersion.objects.filter(app__in=apps)
     else:
         appvers = AppVersion.objects.all()
     lq = {}
     if self.locale is not None:
         lq['code'] = self.locale
     return flag_lists(locales=lq, appversions=avq), appvers, given_app
Example #6
0
 def data_for_avq(self, avq):
     apps = list(AppVersion.objects
                 .filter(**avq)
                 .values_list('app', flat=True)
                 .distinct())
     if len(apps) == 1:
         given_app = Application.objects.get(id=apps[0]).code
     else:
         given_app = None
     if apps:
         appvers = AppVersion.objects.filter(app__in=apps)
     else:
         appvers = AppVersion.objects.all()
     lq = {}
     if self.locale is not None:
         lq['code'] = self.locale
     return flag_lists(locales=lq, appversions=avq), appvers, given_app
Example #7
0
    def get_signoffs(self):
        avq = defaultdict(set)
        if self.avs:
            for appver in (AppVersion.objects
                           .filter(code__in=self.avs).values('id')):
                avq['id__in'].add(appver['id'])

        if self.trees:
            for appver in (AppVersion.objects
                           .filter(tree__code__in=self.trees).values('id')):
                avq['id__in'].add(appver['id'])

        apps = list(AppVersion.objects
                    .filter(**avq)
                    .values_list('app', flat=True)
                    .distinct())
        if len(apps) == 1:
            given_app = Application.objects.get(id=apps[0]).code
        else:
            given_app = None
        if apps:
            appvers = AppVersion.objects.filter(app__in=apps)
        else:
            appvers = AppVersion.objects.all()
        lq = {}
        if self.locales:
            lq['code__in'] = self.locales

        lsd = flag_lists(locales=lq, appversions=avq)
        tree_avs = appvers.exclude(tree__isnull=True)
        tree2av = dict(tree_avs.values_list("tree__code", "code"))
        tree2app = dict(tree_avs.values_list("tree__code", "app__code"))
        items = defaultdict(list)
        values = dict(Action._meta.get_field('flag').flatchoices)
        for k in lsd:
            # ignore tree/locale combos which have no active tree no more
            if k[0] is None:
                continue
            items[k] = [values[so] for so in lsd[k]]
        # get shipped-in data, latest milestone of all appversions for now
        shipped_in = defaultdict(list)
        for _av in appvers.select_related('app'):
            for _ms in _av.milestone_set.filter(status=2).order_by('-pk')[:1]:
                break
            else:
                continue
            app = _av.app.code
            _sos = _ms.signoffs
            if self.locales:
                _sos = _sos.filter(locale__code__in=self.locales)
            for loc in _sos.values_list('locale__code', flat=True):
                shipped_in[(app, loc)].append(_av.code)

        # make a list now
        items = [{"type": "SignOff",
                  "label": "%s/%s" % (tree, locale),
                  "tree": tree,
                  "apploc": ("%s::%s" % (given_app or tree2app[tree],
                                         locale)),
                  "signoff": sorted(values)}
                 for (tree, locale), values in sorted(items.iteritems(),
                                                      key=lambda t:t[0])]
        items += [{"type": "Shippings",
                   "label": "%s::%s" % (av, locale),
                   "shipped": stones}
                  for (av, locale), stones in shipped_in.iteritems()]
        items += [{"type": "AppVer4Tree",
                   "label": tree,
                   "appversion": av}
                  for tree, av in tree2av.iteritems()]
        return items
Example #8
0
 def test_getlist(self):
     """Test that the list returns on accepted and one pending signoff."""
     flags = flag_lists(appversions={"code": "fx1.0"})
     eq_(flags, {("fx", "pl"): [0], ("fx", "de"): [1], ("fx", "fr"): [2]})