Ejemplo n.º 1
0
    def post(self):
        starter = request.environ.get('REMOTE_USER')

        form = ReleasesForm()
        form.readyReleases.choices = [(r.name, r.name) for r in getReleases(ready=False)]
        # Don't include completed or ready releases, because they aren't allowed to be deleted
        form.deleteReleases.choices = [(r.name, r.name) for r in getReleases(complete=False, ready=False)]
        if not form.validate():
            cef_event('User Input Failed', CEF_WARN, **form.errors)
            return make_response(render_template('releases.html', errors=form.errors, releases=sortedReleases(), form=form), 400)

        for release in form.deleteReleases.data:
            log.debug('%s is being deleted', release)
            table = getReleaseTable(release)
            r = table.query.filter_by(name=release).first()
            db.session.delete(r)
        for release in form.readyReleases.data:
            log.debug('%s is being marked as ready', release)
            table = getReleaseTable(release)
            r = table.query.filter_by(name=release).first()
            r.ready = True
            r.status = 'Pending'
            r.comment = form.comment.data
            r.starter = starter
            db.session.add(r)
        db.session.commit()
        return render_template('releases.html', releases=sortedReleases(), form=form)
Ejemplo n.º 2
0
    def post(self):
        starter = request.environ.get('REMOTE_USER')

        form = ReleasesForm()
        form.readyReleases.choices = [(r.name, r.name) for r in getReleases(ready=False)]
        # Don't include completed or ready releases, because they aren't allowed to be deleted
        form.deleteReleases.choices = [(r.name, r.name) for r in getReleases(complete=False, ready=False)]
        if not form.validate():
            cef_event('User Input Failed', CEF_WARN, **form.errors)
            return make_response(render_template('releases.html', errors=form.errors, releases=sortedReleases(), form=form), 400)

        for release in form.deleteReleases.data:
            log.debug('%s is being deleted', release)
            table = getReleaseTable(release)
            r = table.query.filter_by(name=release).first()
            db.session.delete(r)
        for release in form.readyReleases.data:
            log.debug('%s is being marked as ready', release)
            table = getReleaseTable(release)
            r = table.query.filter_by(name=release).first()
            r.ready = True
            r.status = 'Pending'
            r.comment = form.comment.data
            r.starter = starter
            db.session.add(r)
        db.session.commit()
        return render_template('releases.html', releases=sortedReleases(ready=False), form=form)
Ejemplo n.º 3
0
    def post(self, releaseName):
        releaseTable = getReleaseTable(releaseName)
        release = releaseTable.query.filter_by(name=releaseName).first()

        if not release:
            abort(404)

        form = EditReleaseForm(request.form, release)

        if not form.validate():
            errors = []
            for error in form.errors.values():
                errors.extend(error)

            return make_response(render_template('edit_release.html', errors=errors, form=form, release=release), 400)

        form.populate_obj(release)

        if form.isShipped.data:
            release.shippedAt = form.shippedAt
            release.status = 'postrelease'
        else:
            release.shippedAt = None
            release.status = 'Started'

        db.session.add(release)
        db.session.commit()
        return redirect('releases.html')
Ejemplo n.º 4
0
    def post(self, releaseName):
        table = getReleaseTable(releaseName)
        release = table.query.filter_by(name=releaseName).first()
        form = ReleaseAPIForm()
        if not form.validate(release):
            errors = form.errors
            cef_event('User Input Failed', CEF_INFO, **errors)
            errorsStr = ', '.join("%s" % val[0] for val in errors.values())
            return Response(status=400, response=errorsStr)

        # All of the validation has already been done by the form so we can
        # safely assume that the values we have are valid.
        if form.ready.data is not None:
            log.debug('%s: ready being changed to: %s', releaseName,
                      form.ready.data)
            release.ready = form.ready.data
        if form.complete.data is not None:
            log.debug('%s: complete being changed to: %s', releaseName,
                      form.complete.data)
            release.complete = form.complete.data
        if form.status.data:
            log.debug('%s: status being changed to: %s', releaseName,
                      form.status.data)
            release.status = form.status.data
        if form.enUSPlatforms.data:
            log.debug('%s: enUSPlatforms being changed to: %s', releaseName,
                      form.enUSPlatforms.data)
            release.enUSPlatforms = form.enUSPlatforms.data
        log.debug('%s: shippedAt being changed to: %s', releaseName,
                  form.shippedAt.data)
        release.shippedAt = form.shippedAt.data

        db.session.add(release)
        db.session.commit()
        return Response(status=200)
Ejemplo n.º 5
0
    def post(self, releaseName):
        table = getReleaseTable(releaseName)
        release = table.query.filter_by(name=releaseName).first()
        form = ReleaseAPIForm()
        if not form.validate(release):
            errors = form.errors
            cef_event('User Input Failed', CEF_INFO, **errors)
            errorsStr = ', '.join("%s" % val[0] for val in errors.values())
            return Response(status=400, response=errorsStr)

        # All of the validation has already been done by the form so we can
        # safely assume that the values we have are valid.
        if form.ready.data is not None:
            log.debug('%s: ready being changed to: %s', releaseName, form.ready.data)
            release.ready = form.ready.data
        if form.complete.data is not None:
            log.debug('%s: complete being changed to: %s', releaseName, form.complete.data)
            release.complete = form.complete.data
        if form.status.data:
            log.debug('%s: status being changed to: %s', releaseName, form.status.data)
            release.status = form.status.data
        if form.enUSPlatforms.data:
            log.debug('%s: enUSPlatforms being changed to: %s', releaseName, form.enUSPlatforms.data)
            release.enUSPlatforms = form.enUSPlatforms.data

        db.session.add(release)
        db.session.commit()
        return Response(status=200)
Ejemplo n.º 6
0
    def post(self):
        name = request.args.get('name')
        form = getReleaseForm(name)()
        release = getReleaseTable(name).query.filter_by(name=name).first()
        if not release:
            abort(404)
        # Similar to the above, don't allow edits to ready or completed
        # releases. Unless someone has constructed a POST by hand, this code
        # should never be hit.
        if release.ready or release.complete:
            errors = [
                "Cannot update a release that's been marked as ready or is complete"
            ]
            return make_response(
                render_template('release.html',
                                errors=errors,
                                form=form,
                                release=name), 403)

        if not form.validate():
            return make_response(
                render_template('release.html',
                                errors=form.errors.values(),
                                form=form,
                                release=name), 400)

        release.updateFromForm(form)
        db.session.add(release)
        db.session.commit()
        log.debug('%s has been edited', name)
        return redirect('releases.html')
Ejemplo n.º 7
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     release = table.query.filter_by(name=releaseName).first()
     if not release:
         abort(404)
     return Response(status=200, response=release.comment,
                     content_type='text/plain')
Ejemplo n.º 8
0
    def post(self, releaseName):
        releaseTable = getReleaseTable(releaseName)
        release = releaseTable.query.filter_by(name=releaseName).first()

        if not release:
            abort(404)

        form = EditReleaseForm(request.form, release)

        if not form.validate():
            errors = []
            for error in form.errors.values():
                errors.extend(error)

            return make_response(
                render_template('edit_release.html',
                                errors=errors,
                                form=form,
                                release=release), 400)

        form.populate_obj(release)

        if form.isShipped.data:
            release.shippedAt = form.shippedAt
            release.status = 'shipped'
        else:
            release.shippedAt = None
            release.status = 'Started'

        db.session.add(release)
        db.session.commit()
        return redirect('releases.html')
Ejemplo n.º 9
0
def l10nExport(releaseName):
    # Export the l10n changeset for a product
    releaseTable = getReleaseTable(releaseName)
    release = releaseTable.query.filter_by(name=releaseName).first()

    if release is None or release.l10nChangesets == config.LEGACY_KEYWORD:
        return myjsonify({})

    locale_list = defaultdict()
    if "Firefox" in releaseName or "Thunderbird" in releaseName:
        locales = parsePlainL10nChangesets(release.l10nChangesets)
        for key, changeset in locales.iteritems():
            locale_list[key] = {
                "changeset": changeset,
            }

    if "Fennec" in releaseName:
        locales = json.loads(release.l10nChangesets)
        for key, extra in locales.iteritems():
            locale_list[key] = {
                "changeset": extra['revision'],
            }

    l10n_list = {"version": config.JSON_FORMAT_L10N_VERSION,
                 "shippedAt": release.shippedAt,
                 "submittedAt": release.submittedAt,
                 "locales": locale_list,
                 }

    return myjsonify(l10n_list)
Ejemplo n.º 10
0
    def post(self, releaseName):
        table = getReleaseTable(releaseName)
        release = table.query.filter_by(name=releaseName).first()
        form = ReleaseAPIForm()
        if not form.validate(release):
            errors = form.errors
            cef_event('User Input Failed', CEF_INFO, **errors)
            errorsStr = ', '.join("%s" % val[0] for val in errors.values())
            return Response(status=400, response=errorsStr)

        # All of the validation has already been done by the form so we can
        # safely assume that the values we have are valid.
        if form.ready.data is not None:
            log.debug('%s: ready being changed to: %s', releaseName, form.ready.data)
            release.ready = form.ready.data
        if form.complete.data is not None:
            log.debug('%s: complete being changed to: %s', releaseName, form.complete.data)
            release.complete = form.complete.data
        if form.status.data:
            log.debug('%s: status being changed to: %s', releaseName, form.status.data)
            release.status = form.status.data
        if form.description.data:
            log.debug('%s: description being changed to: %s', releaseName, form.description.data)
            release.description = form.description.data
            log.debug('%s: isSecurityDriven being changed to: %s', releaseName, form.isSecurityDriven.data)
            release.isSecurityDriven = form.isSecurityDriven.data
        else:
            # Don't do when we are updating the desc, it would reset the date
            log.debug('%s: shippedAt being changed to: %s', releaseName, form.shippedAt.data)
            release.shippedAt = form.shippedAt.data

        db.session.add(release)
        db.session.commit()
        return Response(status=200)
Ejemplo n.º 11
0
    def addSuggestions(self):
        table = getReleaseTable(self.product.data)
        recentReleases = table.getRecent()

        # Before we make any suggestions we need to do some preprocessing of
        # the data to get it into useful structures. Specifically, we need a
        # set containing all of the recent versions, and a dict that associates
        # them with the branch they were built on.
        recentVersions = set()
        recentBranches = defaultdict(list)
        for release in recentReleases:
            recentVersions.add(release.version)
            recentBranches[release.branch].append(LooseVersion(
                release.version))

        # Now that we have the data in the format we want it in we can start
        # making suggestions.
        suggestedVersions = set()
        buildNumbers = {}

        # This wrapper method is used to centralize the build number suggestion
        # logic in one place, because there's more than one spot below that
        # adds a version suggestion.
        def addVersionSuggestion(version):
            suggestedVersions.add(version)
            # We want the UI to be able to automatically set build number
            # to the next available one for whatever version is entered.
            # To make this work we need to tell it what the next available
            # one is for all existing versions. We don't need to add versions
            # that are on build1, because it uses that as the default.
            maxBuildNumber = table.getMaxBuildNumber(version)
            if maxBuildNumber:
                buildNumbers[version] = maxBuildNumber + 1
            else:
                buildNumbers[version] = 1

        # Every version we see will have its potential next versions
        # suggested, except if we already have that version.
        # Note that we don't look through the entire table for every
        # version (because that could be expensive) but any versions
        # which are suggested and have already happened should be in
        # 'recentVersions', so it's unlikely we'll be suggesting
        # something that has already happened.
        for version in recentVersions:
            for v in getPossibleNextVersions(version):
                if v not in recentVersions:
                    addVersionSuggestion(v)

        # Additional, we need to suggest the most recent version for each
        # branch, because we may want a build2 (or higher) of it.
        for branchVersions in recentBranches.values():
            addVersionSuggestion(str(max(branchVersions)))

        # Finally, attach the suggestions to their fields.
        self.branch.suggestions = json.dumps(list(recentBranches.keys()))
        self.version.suggestions = json.dumps(list(suggestedVersions))
        self.buildNumber.suggestions = json.dumps(buildNumbers)
Ejemplo n.º 12
0
    def addSuggestions(self):
        table = getReleaseTable(self.product.data)
        recentReleases = table.getRecent()

        # Before we make any suggestions we need to do some preprocessing of
        # the data to get it into useful structures. Specifically, we need a
        # set containing all of the recent versions, and a dict that associates
        # them with the branch they were built on.
        recentVersions = set()
        recentBranches = defaultdict(list)
        for release in recentReleases:
            recentVersions.add(release.version)
            recentBranches[release.branch].append(LooseVersion(release.version))

        # Now that we have the data in the format we want it in we can start
        # making suggestions.
        suggestedVersions = set()
        buildNumbers = {}

        # This wrapper method is used to centralize the build number suggestion
        # logic in one place, because there's more than one spot below that
        # adds a version suggestion.
        def addVersionSuggestion(version):
            suggestedVersions.add(version)
            # We want the UI to be able to automatically set build number
            # to the next available one for whatever version is entered.
            # To make this work we need to tell it what the next available
            # one is for all existing versions. We don't need to add versions
            # that are on build1, because it uses that as the default.
            maxBuildNumber = table.getMaxBuildNumber(version)
            if maxBuildNumber:
                buildNumbers[version] = maxBuildNumber + 1
            else:
                buildNumbers[version] = 1

        # Every version we see will have its potential next versions
        # suggested, except if we already have that version.
        # Note that we don't look through the entire table for every
        # version (because that could be expensive) but any versions
        # which are suggested and have already happened should be in
        # 'recentVersions', so it's unlikely we'll be suggesting
        # something that has already happened.
        for version in recentVersions:
            for v in getPossibleNextVersions(version):
                if v not in recentVersions:
                    addVersionSuggestion(v)

        # Additional, we need to suggest the most recent version for each
        # branch, because we may want a build2 (or higher) of it.
        for branchVersions in recentBranches.values():
            addVersionSuggestion(str(max(branchVersions)))

        # Finally, attach the suggestions to their fields.
        self.branch.suggestions = json.dumps(list(recentBranches.keys()))
        self.version.suggestions = json.dumps(list(suggestedVersions))
        self.buildNumber.suggestions = json.dumps(buildNumbers)
Ejemplo n.º 13
0
def l10nExport(releaseName):
    # Export the l10n changeset for a product
    releaseTable = getReleaseTable(releaseName)

    if releaseName.endswith(config.BETA_AGGREGATION_KEYWORD):
        l10n_list = _aggregateBetaLocales(releaseTable, releaseName)
    else:
        l10n_list = _getLocalesByReleaseName(releaseTable, releaseName)

    return myjsonify(l10n_list)
def l10nExport(releaseName):
    # Export the l10n changeset for a product
    releaseTable = getReleaseTable(releaseName)

    if releaseName.endswith(config.BETA_AGGREGATION_KEYWORD):
        l10n_list = _aggregateBetaLocales(releaseTable, releaseName)
    else:
        l10n_list = _getLocalesByReleaseName(releaseTable, releaseName)

    return jsonify_by_sorting_values(l10n_list)
Ejemplo n.º 15
0
    def get(self, releaseName):
        releaseTable = getReleaseTable(releaseName)
        release = releaseTable.query.filter_by(name=releaseName).first()

        if not release:
            abort(404)

        formRelease = EditReleaseForm(obj=release, isShipped=release._shippedAt is not None)

        if release._shippedAt:
            formRelease.shippedAtDate.process_data(release._shippedAt)
            strTime = str(release._shippedAt.time())
            formRelease.shippedAtTime.data = strTime

        return render_template('edit_release.html', form=formRelease, release=release)
Ejemplo n.º 16
0
 def addSuggestions(self):
     ReleaseForm.addSuggestions(self)
     table = getReleaseTable(self.product.data)
     recentReleases = table.getRecentShipped()
     seenVersions = []
     partials = {}
     # The UI will suggest any versions which are on the same branch as
     # the one given, but only the highest build number for that version.
     for release in reversed(recentReleases):
         if release.branch not in partials:
             partials[release.branch] = []
         if release.version not in seenVersions:
             partials[release.branch].append('%sbuild%d' % (release.version, release.buildNumber))
             seenVersions.append(release.version)
     self.partials.suggestions = json.dumps(partials)
Ejemplo n.º 17
0
    def get(self, releaseName):
        releaseTable = getReleaseTable(releaseName)
        release = releaseTable.query.filter_by(name=releaseName).first()

        if not release:
            abort(404)

        formRelease = EditReleaseForm(obj=release, isShipped=release._shippedAt is not None)

        if release._shippedAt:
            formRelease.shippedAtDate.process_data(release._shippedAt)
            strTime = str(release._shippedAt.time())
            formRelease.shippedAtTime.data = strTime

        return render_template('edit_release.html', form=formRelease, release=release)
Ejemplo n.º 18
0
    def post(self):
        # This is checked for in a before_request hook.
        submitter = request.environ.get('REMOTE_USER')
        # We need copies of all the forms to reprint the page if there's any
        # errors. The form that was actually submitted will get overridden with
        # data later on.
        forms = {
            'fennecForm': FennecReleaseForm(formdata=None),
            'firefoxForm': FirefoxReleaseForm(formdata=None),
            'deveditionForm': DeveditionReleaseForm(formdata=None),
            'thunderbirdForm': ThunderbirdReleaseForm(formdata=None)
        }

        for field, value in request.form.items():
            if field.endswith('product'):
                product = value
                break

        try:
            form = getReleaseForm(product)()
        except ValueError:
            cef_event('User Input Failed', CEF_ALERT, ProductName=product)
            return Response(status=400,
                            response="Unknown product name '%s'" % product)
        errors = []
        if not form.validate():
            cef_event('User Input Failed', CEF_INFO, **form.errors)
            for error in form.errors.values():
                errors.extend(error)

        table = getReleaseTable(form.product.data)
        release = table.createFromForm(submitter, form)

        if db.session.query(table).filter(table.name == release.name).first():
            msg = 'Release "%s" already exists' % release.name
            cef_event('User Input Failed', CEF_INFO, ReleaseName=release.name)
            errors.append(msg)
        if errors:
            forms['%sForm' % product] = getReleaseForm(product)()
            return make_response(
                render_template('submit_release.html', errors=errors,
                                selectedProduct=product, **forms), 400
            )

        db.session.add(release)
        db.session.commit()
        log.debug('%s added to the database', release.name)
        return redirect('releases.html')
Ejemplo n.º 19
0
    def post(self):
        # This is checked for in a before_request hook.
        submitter = request.environ.get('REMOTE_USER')
        # We need copies of all the forms to reprint the page if there's any
        # errors. The form that was actually submitted will get overridden with
        # data later on.
        forms = {
            'fennecForm': FennecReleaseForm(formdata=None),
            'firefoxForm': FirefoxReleaseForm(formdata=None),
            'thunderbirdForm': ThunderbirdReleaseForm(formdata=None)
        }

        for field, value in request.form.items():
            if field.endswith('product'):
                product = value
                break

        try:
            form = getReleaseForm(product)()
        except ValueError:
            cef_event('User Input Failed', CEF_ALERT, ProductName=product)
            return Response(status=400,
                            response="Unknown product name '%s'" % product)
        errors = []
        if not form.validate():
            cef_event('User Input Failed', CEF_INFO, **form.errors)
            for error in form.errors.values():
                errors.extend(error)

        table = getReleaseTable(form.product.data)
        release = table.createFromForm(submitter, form)

        if db.session.query(table).filter(table.name == release.name).first():
            msg = 'Release "%s" already exists' % release.name
            cef_event('User Input Failed', CEF_INFO, ReleaseName=release.name)
            errors.append(msg)
        if errors:
            forms['%sForm' % product] = getReleaseForm(product)()
            return make_response(
                render_template('submit_release.html',
                                errors=errors,
                                selectedProduct=product,
                                **forms), 400)

        db.session.add(release)
        db.session.commit()
        log.debug('%s added to the database', release.name)
        return redirect('releases.html')
Ejemplo n.º 20
0
    def get(self):
        name = request.args.get('name')
        form = getReleaseForm(name)()
        release = getReleaseTable(name).query.filter_by(name=name).first()
        if not release:
            abort(404)
        # If this release is already ready or complete, edits aren't allowed.
        # It would be best to display an error here, but considering that there
        # aren't even links to this page for these releases, redirecting back
        # to the list of release seems OK.
        if release.ready or release.complete:
            return redirect('releases.html')

        # If the release is editable, prepopulate the form with the current
        # values from the database.
        form.updateFromRow(release)
        return render_template('release.html', form=form, release=name)
Ejemplo n.º 21
0
    def get(self):
        name = request.args.get('name')
        form = getReleaseForm(name)()
        release = getReleaseTable(name).query.filter_by(name=name).first()
        if not release:
            abort(404)
        # If this release is already ready or complete, edits aren't allowed.
        # It would be best to display an error here, but considering that there
        # aren't even links to this page for these releases, redirecting back
        # to the list of release seems OK.
        if release.ready or release.complete:
            return redirect('releases.html')

        # If the release is editable, prepopulate the form with the current
        # values from the database.
        form.updateFromRow(release)
        return render_template('release.html', form=form, release=name)
Ejemplo n.º 22
0
 def addSuggestions(self):
     ReleaseForm.addSuggestions(self)
     table = getReleaseTable(self.product.data)
     self.recentReleases = table.getRecentShipped()
     seenVersions = []
     partials = defaultdict(list)
     # The UI will suggest any versions which are on the same branch as
     # the one given, but only the highest build number for that version.
     # One exception is Firefox RC builds (version X.0), which should be added
     # to the list of betas
     for release in reversed(self.recentReleases):
         if release.version not in seenVersions:
             partials[release.branch].append('%sbuild%d' % (release.version, release.buildNumber))
             seenVersions.append(release.version)
             # here's the exception
             if release.product == 'firefox' and \
                release.branch == 'releases/mozilla-release' and \
                re.match(r'^\d+\.0$', release.version):
                 partials['releases/mozilla-beta'].append('%sbuild%d' % (release.version, release.buildNumber))
     self.partials.suggestions = json.dumps(partials)
Ejemplo n.º 23
0
    def post(self):
        name = request.args.get('name')
        form = getReleaseForm(name)()
        release = getReleaseTable(name).query.filter_by(name=name).first()
        if not release:
            abort(404)
        # Similar to the above, don't allow edits to ready or completed
        # releases. Unless someone has constructed a POST by hand, this code
        # should never be hit.
        if release.ready or release.complete:
            errors = ["Cannot update a release that's been marked as ready or is complete"]
            return make_response(render_template('release.html', errors=errors, form=form, release=name), 403)

        if not form.validate():
            return make_response(render_template('release.html', errors=form.errors.values(), form=form, release=name), 400)

        release.updateFromForm(form)
        db.session.add(release)
        db.session.commit()
        log.debug('%s has been edited', name)
        return redirect('releases.html')
Ejemplo n.º 24
0
 def addSuggestions(self):
     ReleaseForm.addSuggestions(self)
     table = getReleaseTable(self.product.data)
     self.recentReleases = table.getRecentShipped()
     seenVersions = []
     partials = defaultdict(list)
     # The UI will suggest any versions which are on the same branch as
     # the one given, but only the highest build number for that version.
     # One exception is Firefox RC builds (version X.0), which should be added
     # to the list of betas
     for release in reversed(self.recentReleases):
         if release.version not in seenVersions:
             partials[release.branch].append(
                 '%sbuild%d' % (release.version, release.buildNumber))
             seenVersions.append(release.version)
             # here's the exception
             if release.product == 'firefox' and \
                release.branch == 'releases/mozilla-release' and \
                re.match(r'^\d+\.0$', release.version):
                 partials['releases/mozilla-beta'].append(
                     '%sbuild%d' % (release.version, release.buildNumber))
     self.partials.suggestions = json.dumps(partials)
Ejemplo n.º 25
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     l10n = table.query.filter_by(name=releaseName).first().l10nChangesets
     return Response(status=200, response=l10n, content_type='text/plain')
Ejemplo n.º 26
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     return jsonify(table.query.filter_by(name=releaseName).first().toDict())
Ejemplo n.º 27
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     return jsonify(
         table.query.filter_by(name=releaseName).first().toDict())
Ejemplo n.º 28
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     l10n = table.query.filter_by(name=releaseName).first().l10nChangesets
     return Response(status=200, response=l10n, content_type='text/plain')
Ejemplo n.º 29
0
 def get(self, releaseName):
     table = getReleaseTable(releaseName)
     comment = table.query.filter_by(name=releaseName).first().comment
     return Response(status=200, response=comment, content_type='text/plain')