minchoc 0.0.3__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: minchoc
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Short description of project for PyPI etc.
5
5
  License: MIT
6
6
  Author: Andrew Udvare
@@ -33,3 +33,9 @@ ALLOW_PACKAGE_DELETION = False
33
33
  WANT_NUGET_HOME = False
34
34
  ```
35
35
 
36
+ ## Notes
37
+
38
+ When a user is created, a `NugetUser` is also made. This will contain the API key for pushing.
39
+
40
+ Only `choco install` and `choco push` are supported.
41
+
@@ -13,3 +13,9 @@ INSTALLED_APPS = ['minchoc']
13
13
  ALLOW_PACKAGE_DELETION = False
14
14
  WANT_NUGET_HOME = False
15
15
  ```
16
+
17
+ ## Notes
18
+
19
+ When a user is created, a `NugetUser` is also made. This will contain the API key for pushing.
20
+
21
+ Only `choco install` and `choco push` are supported.
@@ -10,7 +10,7 @@ import django_stubs_ext
10
10
 
11
11
  django_stubs_ext.monkeypatch()
12
12
 
13
- __all__ = ('Author', 'Company', 'NugetUser', 'Package', 'PackageVersionDownloadCount')
13
+ __all__ = ('Author', 'Company', 'NugetUser', 'Package')
14
14
 
15
15
 
16
16
  class Company(models.Model):
@@ -1,4 +1,5 @@
1
1
  # pylint: disable=no-member
2
+ from datetime import datetime
2
3
  from pathlib import Path
3
4
  from tempfile import TemporaryDirectory
4
5
  from typing import Any
@@ -53,7 +54,7 @@ def home(_request: HttpRequest) -> HttpResponse:
53
54
 
54
55
 
55
56
  @require_http_methods(['GET'])
56
- def metadata(_request: HttpRequest, ending: str = '\n') -> HttpResponse:
57
+ def metadata(_request: HttpRequest) -> HttpResponse:
57
58
  return HttpResponse(f'''
58
59
  <?xml version="1.0" encoding="utf-8" standalone="yes"?>
59
60
  <service xml:base="http://fixme/api/v2/"
@@ -64,7 +65,7 @@ def metadata(_request: HttpRequest, ending: str = '\n') -> HttpResponse:
64
65
  <atom:title>Default</atom:title>
65
66
  <collection href="Packages"><atom:title>Packages</atom:title></collection>
66
67
  </workspace>
67
- </service>{ending}''',
68
+ </service>\n''',
68
69
  content_type='application/xml')
69
70
 
70
71
 
@@ -119,17 +120,22 @@ def find_packages_by_id(request: HttpRequest) -> HttpResponse:
119
120
  if (sem_ver_level := request.GET.get('semVerLevel')):
120
121
  logger.warning(f'Ignoring semVerLevel={sem_ver_level}')
121
122
  proto = 'https' if request.is_secure() else 'http'
123
+ proto_host = f'{proto}://{request.get_host()}'
122
124
  try:
123
- return HttpResponse('\n'.join(
124
- make_entry(f'{proto}://{request.get_host()}', x)
125
- for x in Package.objects.filter(nuget_id=request.GET['id'].replace('\'', ''))),
125
+ content = '\n'.join(
126
+ make_entry(proto_host, x)
127
+ for x in Package.objects.filter(nuget_id=request.GET['id'].replace('\'', '')))
128
+ return HttpResponse(f'{FEED_XML_PRE}{content}{FEED_XML_POST}\n' % {
129
+ 'BASEURL': proto_host,
130
+ 'UPDATED': datetime.now().isoformat()
131
+ },
126
132
  content_type='application/xml')
127
133
  except KeyError:
128
134
  return HttpResponse(status=400)
129
135
 
130
136
 
131
137
  @require_http_methods(['GET'])
132
- def packages(request: HttpRequest, ending: str = '\n') -> HttpResponse:
138
+ def packages(request: HttpRequest) -> HttpResponse:
133
139
  filter_ = request.GET.get('$filter')
134
140
  order_by = request.GET.get('$orderby') or 'id'
135
141
  if (sem_ver_level := request.GET.get('semVerLevel')):
@@ -140,10 +146,14 @@ def packages(request: HttpRequest, ending: str = '\n') -> HttpResponse:
140
146
  logger.warning(f'Ignoring $top={top}')
141
147
  filters = filter_parser.parse(filter_) if filter_ else {}
142
148
  proto = 'https' if request.is_secure() else 'http'
149
+ proto_host = f'{proto}://{request.get_host()}'
143
150
  content = '\n'.join(
144
- make_entry(f'{proto}://{request.get_host()}', x)
151
+ make_entry(proto_host, x)
145
152
  for x in Package.objects.order_by(order_by).filter(**filters)[0:20])
146
- return HttpResponse(f'{FEED_XML_PRE}\n{content}{FEED_XML_POST}{ending}',
153
+ return HttpResponse(f'{FEED_XML_PRE}\n{content}{FEED_XML_POST}\n' % {
154
+ 'BASEURL': proto_host,
155
+ 'UPDATED': datetime.now().isoformat()
156
+ },
147
157
  content_type='application/xml')
148
158
 
149
159
 
@@ -151,8 +161,12 @@ def packages(request: HttpRequest, ending: str = '\n') -> HttpResponse:
151
161
  def packages_with_args(request: HttpRequest, name: str, version: str) -> HttpResponse:
152
162
  if (package := Package.objects.filter(nuget_id=name, version=version).first()):
153
163
  proto = 'https' if request.is_secure() else 'http'
154
- content = make_entry(f'{proto}://{request.get_host()}', package)
155
- return HttpResponse(f'{FEED_XML_PRE}\n{content}{FEED_XML_POST}\n',
164
+ proto_host = f'{proto}://{request.get_host()}'
165
+ content = make_entry(proto_host, package)
166
+ return HttpResponse(f'{FEED_XML_PRE}\n{content}{FEED_XML_POST}\n' % {
167
+ 'BASEURL': proto_host,
168
+ 'UPDATED': datetime.now().isoformat()
169
+ },
156
170
  content_type='application/xml')
157
171
  return HttpResponseNotFound()
158
172
 
@@ -252,8 +266,6 @@ class APIV2PackageView(View):
252
266
  new_package.version3 = int(version_split[3])
253
267
  except IndexError:
254
268
  pass
255
- version_download_count = PackageVersionDownloadCount(count=0, version=new_package.version)
256
- version_download_count.save()
257
269
  new_package.size = nuget_file.size
258
270
  new_package.file = File(nuget_file, nuget_file.name) # type: ignore[assignment]
259
271
  uploader = NugetUser.objects.filter(token=request.headers['x-nuget-apikey']).first()
@@ -265,7 +277,6 @@ class APIV2PackageView(View):
265
277
  return HttpResponse(status=400)
266
278
  new_package.tags.add(*add_tags)
267
279
  new_package.authors.add(*add_authors)
268
- new_package.version_download_count.add(version_download_count)
269
280
  return HttpResponse(status=201)
270
281
 
271
282
  def post(self, request: HttpRequest) -> HttpResponse:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "minchoc"
3
- version = "0.0.3"
3
+ version = "0.0.5"
4
4
  authors = ["Andrew Udvare <audvare@gmail.com>"]
5
5
  description = "Short description of project for PyPI etc."
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes