class BundleSerializer(BaseHyperlinkedModelSerializer):
-
web_url = SerializerMethodField()
project = ProjectSerializer(read_only=True)
mbox = SerializerMethodField()
class BundleMixin(object):
-
permission_classes = [PatchworkPermission & BundlePermission]
serializer_class = BundleSerializer
class CheckSerializer(HyperlinkedModelSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-check-detail',
lookup_field_mapping={
class CheckMixin(object):
-
serializer_class = CheckSerializer
filter_class = filterset_class = CheckFilterSet
class BaseCommentListSerializer(BaseHyperlinkedModelSerializer):
-
web_url = SerializerMethodField()
subject = SerializerMethodField()
headers = SerializerMethodField()
class CoverCommentSerializer(BaseCommentListSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-cover-comment-detail',
lookup_field_mapping={
class CoverCommentMixin(object):
-
permission_classes = (PatchworkPermission,)
serializer_class = CoverCommentSerializer
class PatchCommentSerializer(BaseCommentListSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-patch-comment-detail',
lookup_field_mapping={
class PatchCommentMixin(object):
-
permission_classes = (PatchworkPermission,)
serializer_class = PatchCommentSerializer
class CoverListSerializer(BaseHyperlinkedModelSerializer):
-
web_url = SerializerMethodField()
project = ProjectSerializer(read_only=True)
submitter = PersonSerializer(read_only=True)
class CoverDetailSerializer(CoverListSerializer):
-
headers = SerializerMethodField()
def get_headers(self, instance):
class CheckSerializer(SerializedRelatedField):
class _Serializer(BaseHyperlinkedModelSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-check-detail',
lookup_field_mapping={
class CoverCommentSerializer(SerializedRelatedField):
class _Serializer(MboxMixin, WebURLMixin, BaseHyperlinkedModelSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-cover-comment-detail',
lookup_field_mapping={
class PatchCommentSerializer(SerializedRelatedField):
class _Serializer(MboxMixin, WebURLMixin, BaseHyperlinkedModelSerializer):
-
url = NestedHyperlinkedIdentityField(
'api-patch-comment-detail',
lookup_field_mapping={
class ProjectSerializer(SerializedRelatedField):
class _Serializer(BaseHyperlinkedModelSerializer):
-
link_name = CharField(max_length=255, source='linkname')
list_id = CharField(max_length=255, source='listid')
list_email = CharField(max_length=200, source='listemail')
class UserProfileSerializer(SerializedRelatedField):
class _Serializer(BaseHyperlinkedModelSerializer):
-
username = CharField(source='user.username')
first_name = CharField(source='user.first_name')
last_name = CharField(source='user.last_name')
class EventSerializer(ModelSerializer):
-
project = ProjectSerializer(read_only=True)
actor = UserSerializer()
patch = PatchSerializer(read_only=True)
class BaseField(ModelMultipleChoiceField):
-
alternate_lookup = None
class BaseFilter(ModelMultipleChoiceFilter):
-
field_class = BaseField
class PersonChoiceField(ModelMultipleChoiceField):
-
alternate_lookup = 'email__iexact'
class PersonFilter(ModelMultipleChoiceFilter):
-
field_class = PersonChoiceField
class ProjectChoiceField(ModelMultipleChoiceField):
-
alternate_lookup = 'linkname__iexact'
class ProjectFilter(ModelMultipleChoiceFilter):
-
field_class = ProjectChoiceField
class StateFilter(ModelMultipleChoiceFilter):
-
field_class = StateChoiceField
class UserChoiceField(ModelMultipleChoiceField):
-
alternate_lookup = 'username__iexact'
class UserFilter(ModelMultipleChoiceFilter):
-
field_class = UserChoiceField
class TimestampMixin(BaseFilterSet):
-
# TODO(stephenfin): These should filter on a 'updated_at' field instead
before = IsoDateTimeFilter(lookup_expr='lt', field_name='date')
since = IsoDateTimeFilter(lookup_expr='gte', field_name='date')
class SeriesFilterSet(TimestampMixin, BaseFilterSet):
-
submitter = PersonFilter(queryset=Person.objects.all(), distinct=False)
project = ProjectFilter(queryset=Project.objects.all(), distinct=False)
class CoverFilterSet(TimestampMixin, BaseFilterSet):
-
project = ProjectFilter(queryset=Project.objects.all(), distinct=False)
# NOTE(stephenfin): We disable the select-based HTML widgets for these
# filters as the resulting query is _huge_
class PatchFilterSet(TimestampMixin, BaseFilterSet):
-
project = ProjectFilter(queryset=Project.objects.all(), distinct=False)
# NOTE(stephenfin): We disable the select-based HTML widgets for these
# filters as the resulting query is _huge_
class CheckFilterSet(TimestampMixin, BaseFilterSet):
-
user = UserFilter(queryset=User.objects.all(), distinct=False)
class Meta:
class EventFilterSet(TimestampMixin, BaseFilterSet):
-
# NOTE(stephenfin): We disable the select-based HTML widgets for these
# filters as the resulting query is _huge_
# TODO(stephenfin): We should really use an AJAX widget of some form here
class BundleFilterSet(BaseFilterSet):
-
project = ProjectFilter(queryset=Project.objects.all(), distinct=False)
owner = UserFilter(queryset=User.objects.all(), distinct=False)
class PatchListSerializer(BaseHyperlinkedModelSerializer):
-
web_url = SerializerMethodField()
project = ProjectSerializer(read_only=True)
state = StateField()
class PatchDetailSerializer(PatchListSerializer):
-
headers = SerializerMethodField()
prefixes = SerializerMethodField()
class PersonSerializer(HyperlinkedModelSerializer):
-
user = UserSerializer(read_only=True)
class Meta:
class PersonMixin(object):
-
permission_classes = (IsAuthenticated,)
serializer_class = PersonSerializer
class ProjectSerializer(BaseHyperlinkedModelSerializer):
-
link_name = CharField(max_length=255, source='linkname', read_only=True)
list_id = CharField(max_length=255, source='listid', read_only=True)
list_email = CharField(max_length=200, source='listemail', read_only=True)
class ProjectMixin(object):
-
permission_classes = (PatchworkPermission,)
serializer_class = ProjectSerializer
class SeriesSerializer(BaseHyperlinkedModelSerializer):
-
web_url = SerializerMethodField()
project = ProjectSerializer(read_only=True)
submitter = PersonSerializer(read_only=True)
class SeriesMixin(object):
-
permission_classes = (PatchworkPermission,)
serializer_class = SeriesSerializer
class UserMixin(object):
-
queryset = User.objects.all()
permission_classes = (permissions.IsAuthenticated, IsOwnerOrReadOnly)
class PatchworkAppConfig(AppConfig):
-
name = 'patchwork'
verbose_name = 'Patchwork'
def key(self, key):
self.archive_state = False
self.applied = True
- for (k, v) in self.param_map.items():
+ for k, v in self.param_map.items():
if key == v:
self.archive_state = k
if self.archive_state is None:
def querystring(self, remove=None):
params = self.params
- for (k, v) in self.values.items():
+ for k, v in self.values.items():
if k not in params:
params[k] = v
class OptionalModelChoiceField(forms.ModelChoiceField):
-
no_change_choice = ('*', 'no change')
to_field_name = None
class MultiplePatchForm(forms.Form):
-
action = 'update'
archived = OptionalBooleanField(
choices=[
def handle(self, *args, **kwargs):
errors = send_notifications()
- for (recipient, error) in errors:
+ for recipient, error in errors:
self.stderr.write(
"Failed sending to %s: %s" % (recipient.email, error)
)
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
class Migration(migrations.Migration):
-
replaces = [
('patchwork', '0001_initial'),
('patchwork', '0002_fix_patch_state_default_values'),
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0001_initial'),
]
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0002_fix_patch_state_default_values'),
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0003_add_check_model'),
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0004_add_delegation_rule_model'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0005_unselectable_maintainer_projects'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0006_add_patch_diff'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0007_move_comment_content_to_patch_content'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0008_add_email_mixin'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0009_add_submission_model'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0010_migrate_data_from_submission_to_patch'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0011_remove_temp_fields'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0012_add_coverletter_model'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0013_slug_check_context'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0014_remove_userprofile_primary_project'),
]
class Migration(migrations.Migration):
-
# This is necessary due to a mistake made when writing the migration.
# PostgreSQL does not allow mixing of schema and data migrations within the
# same transaction. Disabling transactions ensures this doesn't happen.
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0016_series_project'),
]
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0017_improved_delegation_rule_docs'),
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0018_add_event_model'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0019_userprofile_show_ids'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0020_tag_show_column'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0021_django_1_10_fixes'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0022_add_subject_match_to_project'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0024_patch_patch_project'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0025_add_regex_validators'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0026_add_user_bundles_backref'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0027_remove_series_ordering'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0028_add_comment_date_index'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0029_add_list_covering_index'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0030_add_submission_covering_index'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0031_add_patch_series_fields'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0032_migrate_data_from_series_patch_to_patch'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0033_remove_patch_series_model'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0034_project_list_archive_url'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0035_project_list_archive_url_format'),
]
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0036_project_commit_url_format'),
def populate_slug_field(apps, schema_editor):
-
State = apps.get_model('patchwork', 'State')
with transaction.atomic():
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0037_event_actor'),
]
class Migration(migrations.Migration):
-
dependencies = [('patchwork', '0038_state_slug')]
operations = [
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0039_unique_series_references'),
]
class Migration(migrations.Migration):
-
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('patchwork', '0040_add_related_patches'),
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0041_python3'),
]
class Migration(migrations.Migration):
-
atomic = False
dependencies = [
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0043_merge_patch_submission'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0044_add_project_linkname_validation'),
]
class Migration(migrations.Migration):
-
dependencies = [
('patchwork', '0045_addressed_fields'),
]
class Patch(SubmissionMixin):
-
diff = models.TextField(null=True, blank=True)
commit_ref = models.CharField(max_length=255, null=True, blank=True)
pull_url = models.CharField(max_length=255, null=True, blank=True)
class CoverComment(EmailMixin, models.Model):
-
cover = models.ForeignKey(
Cover,
related_name='comments',
class PatchComment(EmailMixin, models.Model):
-
patch = models.ForeignKey(
Patch,
related_name='comments',
errors = []
- for (recipient, notifications) in groups:
+ for recipient, notifications in groups:
notifications = list(notifications)
if recipient.id not in qs2 or qs2[recipient.id] < len(notifications):
class Paginator(paginator.Paginator):
def __init__(self, request, objects):
-
items_per_page = settings.DEFAULT_ITEMS_PER_PAGE
if request.user.is_authenticated:
class DuplicateSeriesError(Exception):
-
pass
new_value = []
- for (part, _) in value:
+ for part, _ in value:
# We have random bytes that aren't properly coded.
# If we had a coding hint, it failed to help.
@receiver(pre_save, sender=Patch)
def create_series_completed_event(sender, instance, raw, **kwargs):
-
# NOTE(stephenfin): It's actually possible for this event to be fired
# multiple times for a given series. To trigger this case, you would need
# to send an additional patch to already exisiting series. This pattern
def __init__(self, kwargs):
super(ListURLNode, self).__init__(None, [], {}, False)
self.params = {}
- for (k, v) in kwargs.items():
+ for k, v in kwargs.items():
if k in list_params:
self.params[k] = v
except (TypeError, template.VariableDoesNotExist):
pass
- for (k, v) in self.params.items():
+ for k, v in self.params.items():
params[smart_str(k, 'ascii')] = v.resolve(context)
if not params:
@register.filter
def personify(person, project):
-
if person.name:
linktext = escape(person.name)
else:
def commentsyntax(submission):
content = escape(submission.content)
- for (r, cls) in _comment_span_res:
+ for r, cls in _comment_span_res:
content = r.sub(lambda x: _span % (cls, x.group(0)), content)
return mark_safe(content)
def client_wrapper(
orig_func, path, data=None, *orig_args, **orig_kwargs
):
-
req_filename = filename + '-req.json'
resp_filename = filename + '-resp.json'
class InlinePatchTest(PatchTest):
-
orig_content = 'Test for attached patch'
orig_diff = read_patch('0001-add-line.patch')
class AttachmentPatchTest(InlinePatchTest):
-
orig_content = 'Test for attached patch'
content_subtype = 'x-patch'
class AttachmentXDiffPatchTest(AttachmentPatchTest):
-
content_subtype = 'x-diff'
class UTF8InlinePatchTest(InlinePatchTest):
-
orig_diff = read_patch('0002-utf-8.patch', 'utf-8')
def setUp(self):
class SignatureCommentTest(InlinePatchTest):
-
orig_content = 'Test comment\nmore comment'
def setUp(self):
class ListFooterTest(InlinePatchTest):
-
orig_content = 'Test comment\nmore comment'
def setUp(self):
class DiffWordInCommentTest(InlinePatchTest):
-
orig_content = (
'Lines can start with words beginning in "diff"\n'
+ 'difficult\nDifferent'
class DelegateRequestTest(TestCase):
-
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
invalid_delegate_email = "nobody"
class CommentActionRequiredTest(TestCase):
-
fixtures = ['default_tags']
def setUp(self):
class InitialPatchStateTest(TestCase):
-
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
invalid_state_name = "Nonexistent Test State"
class ParseInitialTagsTest(PatchTest):
-
fixtures = ['default_tags']
patch_filename = '0001-add-line.patch'
orig_content = (
class ExtractTagsTest(TestCase):
-
fixtures = ['default_tags']
email = 'test@example.com'
name_email = 'test name <' + email + '>'
class PatchTagsTest(TransactionTestCase):
-
fixtures = ['default_tags']
ACK = 1
REVIEW = 2
class XMLRPCFilterModelTestMixin(XMLRPCModelTestMixin):
-
# override these tests due to the way you pass in filters
def test_list_max_count(self):
objs = self.create_multiple(5)
# BundlePatches should be sorted by .order by default
bps = BundlePatch.objects.filter(bundle=bundle)
- for (bp, p) in zip(bps, expected_order):
+ for bp, p in zip(bps, expected_order):
self.assertEqual(bp.patch.pk, p.pk)
bundle.delete()
class PatchListOrderingTest(TestCase):
-
patchmeta = [
(
'AlCMyjOsx',
class PatchUpdateTest(TestCase):
-
properties_form_id = 'patchform-properties'
def setUp(self):
def get_patch_ids(d, prefix='patch_id'):
ids = []
- for (k, v) in d.items():
+ for k, v in d.items():
a = k.split(':')
if len(a) != 2:
continue
patches=None,
editable_order=False,
):
-
if not filter_settings:
filter_settings = []
if errors:
context['errors'] = errors
- for (filterclass, setting) in filter_settings:
+ for filterclass, setting in filter_settings:
if isinstance(setting, dict):
context['filters'].set_status(filterclass, **setting)
elif isinstance(setting, list):
def confirm(request, key):
-
views = {
'userperson': user.link_confirm,
'registration': user.register_confirm,
class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher, XMLRPCDocGenerator):
-
server_name = 'Patchwork XML-RPC API'
server_title = 'Patchwork XML-RPC API v1 Documentation'
if not patch.is_editable(user):
raise Exception('No permissions to edit this patch')
- for (k, v) in params.items():
+ for k, v in params.items():
if k not in ok_params:
continue