Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2827 from eviljeff/amo-be-gone
Browse files Browse the repository at this point in the history
amo be gone (bug 1042820)
  • Loading branch information
eviljeff committed Jan 10, 2015
2 parents dec18ea + 45f846d commit ecb150c
Show file tree
Hide file tree
Showing 189 changed files with 2,193 additions and 2,237 deletions.
1 change: 0 additions & 1 deletion apps/__init__.py

This file was deleted.

36 changes: 0 additions & 36 deletions apps/amo/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/topics/hacking/testing.rst
Expand Up @@ -46,7 +46,7 @@ To fail and stop running tests on the first failure::
If you wish to add arguments, or run a specific test, overload the variables
(check the Makefile for more information)::

make SETTINGS=settings_mkt ARGS='--verbosity 2 zamboni.apps.amo.tests.test_url_prefix:MiddlewareTest.test_get_app' test
make SETTINGS=settings_mkt ARGS='--verbosity 2 zamboni.mkt.site.tests.test_url_prefix:MiddlewareTest.test_get_app' test

Those targets include some useful options, like the ``--with-id`` which allows
you to re-run only the tests failed from the previous run::
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/install-zamboni/celery.rst
Expand Up @@ -86,7 +86,7 @@ If we run this command like so: ::

all_pks = Webapp.objects.all().values_list('pk', flat=True)
ts = [_update_addons_current_version.subtask(args=[pks])
for pks in amo.utils.chunked(all_pks, 300)]
for pks in mkt.site.utils.chunked(all_pks, 300)]
TaskSet(ts).apply_async()

All the Webapps with ids in ``pks`` will (eventually) have their
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/install-zamboni/elasticsearch.rst
Expand Up @@ -91,7 +91,7 @@ interface to Elasticsearch::
Testing with Elasticsearch
--------------------------

All test cases using Elasticsearch should inherit from ``amo.tests.ESTestCase``.
All test cases using Elasticsearch should inherit from ``mkt.site.tests.ESTestCase``.
All such tests will be skipped by the test runner unless::

RUN_ES_TESTS = True
Expand Down
4 changes: 2 additions & 2 deletions docs/topics/translations.rst
Expand Up @@ -33,10 +33,10 @@ A minimal model with translations in zamboni would look like this::

from django.db import models

import amo.models
import mkt.site.models
import mkt.translations

class MyModel(amo.models.ModelBase):
class MyModel(mkt.site.models.ModelBase):
description = translations.fieldsTranslatedField()

models.signals.pre_save.connect(translations.fields.save_signal,
Expand Down
12 changes: 6 additions & 6 deletions lib/video/tasks.py
Expand Up @@ -6,7 +6,7 @@

from celeryutils import task

import amo
import mkt
import waffle
from lib.video import library
from mkt.site.decorators import set_modified_on
Expand Down Expand Up @@ -37,7 +37,7 @@ def resize_video(src, instance, user=None, **kw):

def _resize_error(src, instance, user):
"""An error occurred in processing the video, deal with that approp."""
amo.log(amo.LOG.VIDEO_ERROR, instance, user=user)
mkt.log(mkt.LOG.VIDEO_ERROR, instance, user=user)
instance.delete()


Expand All @@ -61,7 +61,7 @@ def _resize_video(src, instance, lib=None, **kw):
if waffle.switch_is_active('video-encode'):
# Do the video encoding.
try:
video_file = video.get_encoded(amo.ADDON_PREVIEW_SIZES[1])
video_file = video.get_encoded(mkt.ADDON_PREVIEW_SIZES[1])
except Exception:
log.info('Error encoding video for %s, %s' %
(instance.pk, video.meta), exc_info=True)
Expand All @@ -70,7 +70,7 @@ def _resize_video(src, instance, lib=None, **kw):
# Do the thumbnail next, this will be the signal that the
# encoding has finished.
try:
thumbnail_file = video.get_screenshot(amo.ADDON_PREVIEW_SIZES[0])
thumbnail_file = video.get_screenshot(mkt.ADDON_PREVIEW_SIZES[0])
except Exception:
# We'll have this file floating around because the video
# encoded successfully, or something has gone wrong in which case
Expand All @@ -96,8 +96,8 @@ def _resize_video(src, instance, lib=None, **kw):
# Ensure everyone has read permission on the file.
os.chmod(instance.image_path, 0644)
os.chmod(instance.thumbnail_path, 0644)
instance.sizes = {'thumbnail': amo.ADDON_PREVIEW_SIZES[0],
'image': amo.ADDON_PREVIEW_SIZES[1]}
instance.sizes = {'thumbnail': mkt.ADDON_PREVIEW_SIZES[0],
'image': mkt.ADDON_PREVIEW_SIZES[1]}
instance.save()
log.info('Completed encoding video: %s' % instance.pk)
return True
12 changes: 6 additions & 6 deletions lib/video/tests.py
Expand Up @@ -9,7 +9,7 @@

from django.conf import settings

import amo
import mkt
import mkt.site.tests
from mkt.site.tests.test_utils_ import get_image_path
from lib.video import dummy, ffmpeg, get_library, totem
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_screenshot(self):
raise SkipTest
self.video.get_meta()
try:
screenshot = self.video.get_screenshot(amo.ADDON_PREVIEW_SIZES[0])
screenshot = self.video.get_screenshot(mkt.ADDON_PREVIEW_SIZES[0])
assert os.stat(screenshot)[stat.ST_SIZE]
finally:
os.remove(screenshot)
Expand All @@ -96,7 +96,7 @@ def test_encoded(self):
raise SkipTest
self.video.get_meta()
try:
video = self.video.get_encoded(amo.ADDON_PREVIEW_SIZES[0])
video = self.video.get_encoded(mkt.ADDON_PREVIEW_SIZES[0])
assert os.stat(video)[stat.ST_SIZE]
finally:
os.remove(video)
Expand All @@ -119,11 +119,11 @@ def test_valid(self):

def test_screenshot(self):
self.assertRaises(AssertionError, self.video.get_screenshot,
amo.ADDON_PREVIEW_SIZES[0])
mkt.ADDON_PREVIEW_SIZES[0])

def test_encoded(self):
self.assertRaises(AssertionError, self.video.get_encoded,
amo.ADDON_PREVIEW_SIZES[0])
mkt.ADDON_PREVIEW_SIZES[0])


class TestTotemVideo(mkt.site.tests.TestCase):
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_resize_error(self, _resize_video):
resize_video(files['good'], self.mock, user=user, lib=dummy.Video)
assert self.mock.delete.called
assert UserLog.objects.filter(user=user,
activity_log__action=amo.LOG.VIDEO_ERROR.id).exists()
activity_log__action=mkt.LOG.VIDEO_ERROR.id).exists()

@patch('lib.video.tasks._resize_video')
def test_resize_failed(self, _resize_video):
Expand Down
14 changes: 4 additions & 10 deletions manage.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
import logging
import os
import site
import sys

from django.core.management import execute_from_command_line
Expand All @@ -12,10 +11,10 @@
else:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mkt.settings')

ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)

site.addsitedir(path('apps'))
# waffle and mkt form an import cycle because mkt patches waffle and
# waffle loads the user model, so we have to make sure mkt gets
# imported before anything else imports waffle.
import mkt

import session_csrf
session_csrf.monkeypatch()
Expand All @@ -31,11 +30,6 @@
from lib.log_settings_base import log_configure
log_configure()

# waffle and amo form an import cycle because amo patches waffle and
# waffle loads the user model, so we have to make sure amo gets
# imported before anything else imports waffle.
import amo

# Hardcore monkeypatching action.
import jingo.monkey
jingo.monkey.patch()
Expand Down
8 changes: 4 additions & 4 deletions migrations/503-gaia-device-type.py
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Count

import amo
import mkt
from addons.models import AddonDeviceType as ADT
from mkt.site.utils import chunked
from mkt.site.decorators import write
Expand All @@ -32,14 +32,14 @@ def _task(**kw):
device.delete()

# `DEVICE_MOBILE` -> `DEVICE_MOBILE` and `DEVICE_GAIA`.
devices = ADT.objects.filter(device_type=amo.DEVICE_MOBILE.id)
devices = ADT.objects.filter(device_type=mkt.DEVICE_MOBILE.id)

for chunk in chunked(devices, 50):
for device in chunk:
if amo.DEVICE_GAIA in device.addon.device_types:
if mkt.DEVICE_GAIA in device.addon.device_types:
continue
device.id = None
device.device_type = amo.DEVICE_GAIA.id
device.device_type = mkt.DEVICE_GAIA.id
device.save()
device.addon.save()

Expand Down
3 changes: 1 addition & 2 deletions migrations/532-unleash-payments-in-usa.py
@@ -1,10 +1,9 @@
import amo
import mkt
from mkt.webapps.models import AddonExcludedRegion


def run():
"""Unleash payments in USA."""
(AddonExcludedRegion.objects
.exclude(addon__premium_type=amo.ADDON_FREE)
.exclude(addon__premium_type=mkt.ADDON_FREE)
.filter(region=mkt.regions.US.id).delete())
2 changes: 1 addition & 1 deletion migrations/607-reboot-price-currencies.py
@@ -1,6 +1,6 @@
from django.db import models

import amo
import mkt
from market.models import Price

tiers = {
Expand Down
10 changes: 5 additions & 5 deletions migrations/620-add-mobile-profile.py
@@ -1,14 +1,14 @@
import amo
import mkt
from mkt.webapps.models import AppFeatures, Webapp


def run():
"""Update feature profiles for mobile-only apps requiring qHD."""
apps = (Webapp.objects
.filter(addondevicetype__device_type__in=[amo.DEVICE_MOBILE.id,
amo.DEVICE_GAIA.id])
.exclude(addondevicetype__device_type__in=[amo.DEVICE_TABLET.id,
amo.DEVICE_DESKTOP.id]))
.filter(addondevicetype__device_type__in=[mkt.DEVICE_MOBILE.id,
mkt.DEVICE_GAIA.id])
.exclude(addondevicetype__device_type__in=[mkt.DEVICE_TABLET.id,
mkt.DEVICE_DESKTOP.id]))
for app in apps:
for version in app.versions.all():
af, _ = AppFeatures.objects.get_or_create(version=version)
Expand Down
2 changes: 1 addition & 1 deletion migrations/642-encrypt-secret.py
@@ -1,6 +1,6 @@
from datetime import datetime

import amo
import mkt

from aesfield.field import AESField

Expand Down
4 changes: 2 additions & 2 deletions migrations/661-award-theme-points.py
Expand Up @@ -4,7 +4,7 @@

from django.db.models import Q

import amo
import mkt
import mkt.constants.reviewers as rvw
from mkt.site.utils import chunked
from mkt.developers.models import ActivityLog
Expand All @@ -25,7 +25,7 @@ def run():
reject = '"action": %s' % rvw.ACTION_REJECT
al = ActivityLog.objects.filter(
Q(_details__contains=approve) | Q(_details__contains=reject),
action=amo.LOG.THEME_REVIEW.id, created__lte=start_date)
action=mkt.LOG.THEME_REVIEW.id, created__lte=start_date)

for chunk in chunked(al, 50):
# Review and thou shall receive.
Expand Down
29 changes: 29 additions & 0 deletions mkt/__init__.py
@@ -1,3 +1,32 @@
import threading

from mkt.constants import (categories, comm, platforms, iarc_mappings,
ratingsbodies)
from mkt.constants.applications import *
from mkt.constants.base import *
from mkt.constants.payments import *
from mkt.constants.platforms import *
from mkt.constants.search import *
from mkt.constants.submit import *

# This is used in multiple other files to access logging, do not remove.
from mkt.site.log import (_LOG, LOG, LOG_BY_ID, LOG_ADMINS, LOG_EDITORS,
LOG_HIDE_DEVELOPER, LOG_KEEP, LOG_REVIEW_QUEUE,
LOG_REVIEW_EMAIL_USER, log)

_locals = threading.local()
_locals.user = None


def get_user():
return getattr(_locals, 'user', None)


def set_user(user):
_locals.user = user


# We need to import waffle here to avoid a circular import with jingo which
# loads all INSTALLED_APPS looking for helpers.py files, but some of those apps
# import jingo.
import waffle
14 changes: 7 additions & 7 deletions mkt/access/acl.py
@@ -1,4 +1,4 @@
import amo
import mkt


def match_rules(rules, app, action):
Expand Down Expand Up @@ -70,19 +70,19 @@ def check_addon_ownership(request, addon, viewer=False, dev=False,
if admin and action_allowed(request, 'Apps', 'Edit'):
return True
# Only admins can edit banned addons.
if addon.status == amo.STATUS_DISABLED and not ignore_disabled:
if addon.status == mkt.STATUS_DISABLED and not ignore_disabled:
return False
# Addon owners can do everything else.
roles = (amo.AUTHOR_ROLE_OWNER,)
roles = (mkt.AUTHOR_ROLE_OWNER,)
if dev:
roles += (amo.AUTHOR_ROLE_DEV,)
roles += (mkt.AUTHOR_ROLE_DEV,)
# Viewer privs are implied for devs.
elif viewer:
roles += (amo.AUTHOR_ROLE_DEV, amo.AUTHOR_ROLE_VIEWER,
amo.AUTHOR_ROLE_SUPPORT)
roles += (mkt.AUTHOR_ROLE_DEV, mkt.AUTHOR_ROLE_VIEWER,
mkt.AUTHOR_ROLE_SUPPORT)
# Support can do support.
elif support:
roles += (amo.AUTHOR_ROLE_SUPPORT,)
roles += (mkt.AUTHOR_ROLE_SUPPORT,)
return addon.authors.filter(pk=request.user.pk,
addonuser__role__in=roles).exists()

Expand Down
8 changes: 4 additions & 4 deletions mkt/access/middleware.py
Expand Up @@ -6,7 +6,7 @@

import commonware.log

import amo
import mkt
from mkt.access import acl


Expand All @@ -21,12 +21,12 @@ def process_request(self, request):

# figure out our list of groups...
if request.user.is_authenticated():
amo.set_user(request.user)
mkt.set_user(request.user)
request.groups = request.user.groups.all()

def process_response(self, request, response):
amo.set_user(None)
mkt.set_user(None)
return response

def process_exception(self, request, exception):
amo.set_user(None)
mkt.set_user(None)

0 comments on commit ecb150c

Please sign in to comment.