def create_comm_thread(self, **kwargs): res = create_comm_thread(action=kwargs['action'], addon=self.addon, comments=self.data['comments'], perms=self.data['action_visibility'], profile=self.request.amo_user, version=self.version) if res: self.comm_thread, self.comm_note = res
def version_edit(request, addon_id, addon, version_id): show_features = waffle.switch_is_active("buchets") and addon.is_packaged formdata = request.POST if request.method == "POST" else None version = get_object_or_404(Version, pk=version_id, addon=addon) version.addon = addon # Avoid extra useless query. form = AppVersionForm(formdata, instance=version) all_forms = [form] if show_features: appfeatures = version.features appfeatures_form = AppFeaturesForm(request.POST or None, instance=appfeatures) all_forms.append(appfeatures_form) if request.method == "POST" and all(f.is_valid() for f in all_forms): [f.save() for f in all_forms] # Make note visible to reviewers, senior reviewers and staff. comm_perms = ("reviewer", "senior_reviewer", "staff") create_comm_thread( addon=addon, version=version, action="comment", perms=comm_perms, comments=f.data["approvalnotes"], profile=request.amo_user, ) messages.success(request, _("Version successfully edited.")) return redirect(addon.get_dev_url("versions")) context = {"addon": addon, "version": version, "form": form} if show_features: context.update( { "appfeatures_form": appfeatures_form, "appfeatures": appfeatures, "feature_list": [unicode(f) for f in appfeatures.to_list()], } ) return jingo.render(request, "developers/apps/version_edit.html", context)
def version_edit(request, addon_id, addon, version_id): show_features = waffle.switch_is_active('buchets') and addon.is_packaged formdata = request.POST if request.method == 'POST' else None version = get_object_or_404(Version, pk=version_id, addon=addon) version.addon = addon # Avoid extra useless query. form = AppVersionForm(formdata, instance=version) all_forms = [form] if show_features: appfeatures = version.features appfeatures_form = AppFeaturesForm(request.POST or None, instance=appfeatures) all_forms.append(appfeatures_form) if request.method == 'POST' and all(f.is_valid() for f in all_forms): [f.save() for f in all_forms] # Make note visible to reviewers, senior reviewers and staff. comm_perms = ('reviewer', 'senior_reviewer', 'staff') create_comm_thread(addon=addon, version=version, action='comment', perms=comm_perms, comments=f.data['approvalnotes'], profile=request.amo_user) messages.success(request, _('Version successfully edited.')) return redirect(addon.get_dev_url('versions')) context = {'addon': addon, 'version': version, 'form': form} if show_features: context.update({ 'appfeatures_form': appfeatures_form, 'appfeatures': appfeatures, 'feature_list': [unicode(f) for f in appfeatures.to_list()] }) return jingo.render(request, 'developers/apps/version_edit.html', context)
def version_edit(request, addon_id, addon, version_id): show_features = waffle.switch_is_active('buchets') and addon.is_packaged formdata = request.POST if request.method == 'POST' else None version = get_object_or_404(Version, pk=version_id, addon=addon) version.addon = addon # Avoid extra useless query. form = AppVersionForm(formdata, instance=version) all_forms = [form] if show_features: appfeatures = version.features appfeatures_form = AppFeaturesForm(request.POST or None, instance=appfeatures) all_forms.append(appfeatures_form) if request.method == 'POST' and all(f.is_valid() for f in all_forms): [f.save() for f in all_forms] # Make note visible to reviewers, senior reviewers and staff. comm_perms = ('reviewer', 'senior_reviewer', 'staff') create_comm_thread(addon=addon, version=version, action='comment', perms=comm_perms, comments=f.data['approvalnotes'], profile=request.amo_user) messages.success(request, _('Version successfully edited.')) return redirect(addon.get_dev_url('versions')) context = { 'addon': addon, 'version': version, 'form': form } if show_features: context.update({ 'appfeatures_form': appfeatures_form, 'appfeatures': appfeatures, 'feature_list': [unicode(f) for f in appfeatures.to_list()] }) return jingo.render(request, 'developers/apps/version_edit.html', context)
def status(request, addon_id, addon, webapp=False): form = forms.AppAppealForm(request.POST, product=addon) upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True, addon=addon, request=request) if request.method == 'POST': if 'resubmit-app' in request.POST and form.is_valid(): form.save() perms = ('reviewer', 'senior_reviewer', 'staff') create_comm_thread(action='resubmit', addon=addon, comments=form.data['notes'], profile=request.amo_user, version=addon.current_version, perms=perms) messages.success(request, _('App successfully resubmitted.')) return redirect(addon.get_dev_url('versions')) elif 'upload-version' in request.POST and upload_form.is_valid(): mobile_only = (addon.latest_version and addon.latest_version.features.has_qhd) ver = Version.from_upload(upload_form.cleaned_data['upload'], addon, [amo.PLATFORM_ALL]) # Update addon status now that the new version was saved. addon.update_status() res = run_validator(ver.all_files[0].file_path) validation_result = json.loads(res) # Set all detected features as True and save them. keys = ['has_%s' % feature.lower() for feature in validation_result['feature_profile']] data = defaultdict.fromkeys(keys, True) # Set "Smartphone-Sized Displays" if it's a mobile-only app. qhd_devices = (set((amo.DEVICE_GAIA,)), set((amo.DEVICE_MOBILE,)), set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE,))) if set(addon.device_types) in qhd_devices or mobile_only: data['has_qhd'] = True # Update feature profile for this version. ver.features.update(**data) messages.success(request, _('New version successfully added.')) log.info('[Webapp:%s] New version created id=%s from upload: %s' % (addon, ver.pk, upload_form.cleaned_data['upload'])) return redirect(addon.get_dev_url('versions.edit', args=[ver.pk])) ctx = {'addon': addon, 'webapp': webapp, 'form': form, 'upload_form': upload_form} # Used in the delete version modal. if addon.is_packaged: versions = addon.versions.values('id', 'version') version_strings = dict((v['id'], v) for v in versions) version_strings['num'] = len(versions) ctx['version_strings'] = json.dumps(version_strings) if addon.status == amo.STATUS_REJECTED: try: entry = (AppLog.objects .filter(addon=addon, activity_log__action=amo.LOG.REJECT_VERSION.id) .order_by('-created'))[0] except IndexError: entry = None # This contains the rejection reason and timestamp. ctx['rejection'] = entry and entry.activity_log if waffle.switch_is_active('preload-apps'): test_plan = PreloadTestPlan.objects.filter( addon=addon, status=amo.STATUS_PUBLIC) if test_plan.exists(): test_plan = test_plan[0] if (test_plan.last_submission < settings.PREINSTALL_TEST_PLAN_LATEST): ctx['outdated_test_plan'] = True ctx['next_step_suffix'] = 'submit' else: ctx['next_step_suffix'] = 'home' ctx['test_plan'] = test_plan return jingo.render(request, 'developers/apps/status.html', ctx)
def status(request, addon_id, addon, webapp=False): form = forms.AppAppealForm(request.POST, product=addon) upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True, addon=addon, request=request) if request.method == 'POST': if 'resubmit-app' in request.POST and form.is_valid(): form.save() perms = ('reviewer', 'senior_reviewer', 'staff') create_comm_thread(action='resubmit', addon=addon, comments=form.data['notes'], profile=request.amo_user, version=addon.current_version, perms=perms) messages.success(request, _('App successfully resubmitted.')) return redirect(addon.get_dev_url('versions')) elif 'upload-version' in request.POST and upload_form.is_valid(): mobile_only = (addon.latest_version and addon.latest_version.features.has_qhd) ver = Version.from_upload(upload_form.cleaned_data['upload'], addon, [amo.PLATFORM_ALL]) # Update addon status now that the new version was saved. addon.update_status() res = run_validator(ver.all_files[0].file_path) validation_result = json.loads(res) # Set all detected features as True and save them. keys = [ 'has_%s' % feature.lower() for feature in validation_result['feature_profile'] ] data = defaultdict.fromkeys(keys, True) # Set "Smartphone-Sized Displays" if it's a mobile-only app. qhd_devices = (set((amo.DEVICE_GAIA, )), set( (amo.DEVICE_MOBILE, )), set(( amo.DEVICE_GAIA, amo.DEVICE_MOBILE, ))) if set(addon.device_types) in qhd_devices or mobile_only: data['has_qhd'] = True # Update feature profile for this version. ver.features.update(**data) messages.success(request, _('New version successfully added.')) log.info('[Webapp:%s] New version created id=%s from upload: %s' % (addon, ver.pk, upload_form.cleaned_data['upload'])) return redirect(addon.get_dev_url('versions.edit', args=[ver.pk])) ctx = { 'addon': addon, 'webapp': webapp, 'form': form, 'upload_form': upload_form } # Used in the delete version modal. if addon.is_packaged: versions = addon.versions.values('id', 'version') version_strings = dict((v['id'], v) for v in versions) version_strings['num'] = len(versions) ctx['version_strings'] = json.dumps(version_strings) if addon.status == amo.STATUS_REJECTED: try: entry = (AppLog.objects.filter( addon=addon, activity_log__action=amo.LOG.REJECT_VERSION.id).order_by( '-created'))[0] except IndexError: entry = None # This contains the rejection reason and timestamp. ctx['rejection'] = entry and entry.activity_log return jingo.render(request, 'developers/apps/status.html', ctx)
def status(request, addon_id, addon, webapp=False): form = forms.AppAppealForm(request.POST, product=addon) upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True, addon=addon, request=request) if request.method == "POST": if "resubmit-app" in request.POST and form.is_valid(): form.save() perms = ("reviewer", "senior_reviewer", "staff") create_comm_thread( action="resubmit", addon=addon, comments=form.data["notes"], profile=request.amo_user, version=addon.current_version, perms=perms, ) messages.success(request, _("App successfully resubmitted.")) return redirect(addon.get_dev_url("versions")) elif "upload-version" in request.POST and upload_form.is_valid(): mobile_only = addon.latest_version and addon.latest_version.features.has_qhd ver = Version.from_upload(upload_form.cleaned_data["upload"], addon, [amo.PLATFORM_ALL]) # Update addon status now that the new version was saved. addon.update_status() res = run_validator(ver.all_files[0].file_path) validation_result = json.loads(res) # Set all detected features as True and save them. keys = ["has_%s" % feature.lower() for feature in validation_result["feature_profile"]] data = defaultdict.fromkeys(keys, True) # Set "Smartphone-Sized Displays" if it's a mobile-only app. qhd_devices = ( set((amo.DEVICE_GAIA,)), set((amo.DEVICE_MOBILE,)), set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE)), ) if set(addon.device_types) in qhd_devices or mobile_only: data["has_qhd"] = True # Update feature profile for this version. ver.features.update(**data) messages.success(request, _("New version successfully added.")) log.info( "[Webapp:%s] New version created id=%s from upload: %s" % (addon, ver.pk, upload_form.cleaned_data["upload"]) ) return redirect(addon.get_dev_url("versions.edit", args=[ver.pk])) ctx = {"addon": addon, "webapp": webapp, "form": form, "upload_form": upload_form} # Used in the delete version modal. if addon.is_packaged: versions = addon.versions.values("id", "version") version_strings = dict((v["id"], v) for v in versions) version_strings["num"] = len(versions) ctx["version_strings"] = json.dumps(version_strings) if addon.status == amo.STATUS_REJECTED: try: entry = ( AppLog.objects.filter(addon=addon, activity_log__action=amo.LOG.REJECT_VERSION.id).order_by("-created") )[0] except IndexError: entry = None # This contains the rejection reason and timestamp. ctx["rejection"] = entry and entry.activity_log return jingo.render(request, "developers/apps/status.html", ctx)