зеркало из https://github.com/nextcloud/appstore.git
Merge branch 'master' into token_auth
This commit is contained in:
Коммит
4037c5820b
|
@ -161,6 +161,11 @@ class AppReleaseImporter(Importer):
|
|||
obj.databases.clear()
|
||||
|
||||
def import_data(self, key: str, value: Any, obj: Any) -> None:
|
||||
# if this is a nightly, delete all other nightlies
|
||||
if value['version'].endswith('-nightly'):
|
||||
AppRelease.objects.filter(
|
||||
app__id=obj.id, version__endswith='-nightly').delete()
|
||||
|
||||
# combine versions into specs
|
||||
value['platform_version_spec'] = to_spec(
|
||||
value['platform_min_version'], value['platform_max_version'])
|
||||
|
@ -198,6 +203,7 @@ class AppImporter(Importer):
|
|||
# only new releases update an app's data
|
||||
if not self._is_latest_version(value):
|
||||
value = {'id': value['id'], 'release': value['release']}
|
||||
|
||||
super().import_data(key, value, obj)
|
||||
|
||||
def _get_object(self, value: Any, obj: Any) -> Any:
|
||||
|
|
|
@ -46,13 +46,16 @@ class AppReleaseSerializer(serializers.ModelSerializer):
|
|||
source='phpextensiondependencies')
|
||||
php_version_spec = SerializerMethodField()
|
||||
platform_version_spec = SerializerMethodField()
|
||||
version = SerializerMethodField()
|
||||
nightly = SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = AppRelease
|
||||
fields = (
|
||||
'version', 'php_extensions', 'databases', 'shell_commands',
|
||||
'php_version_spec', 'platform_version_spec', 'min_int_size',
|
||||
'download', 'created', 'licenses', 'last_modified', 'checksum'
|
||||
'download', 'created', 'licenses', 'last_modified', 'checksum',
|
||||
'nightly',
|
||||
)
|
||||
|
||||
def get_platform_version_spec(self, obj):
|
||||
|
@ -61,6 +64,12 @@ class AppReleaseSerializer(serializers.ModelSerializer):
|
|||
def get_php_version_spec(self, obj):
|
||||
return obj.php_version_spec.replace(',', ' ')
|
||||
|
||||
def get_version(self, obj):
|
||||
return obj.version.replace('-nightly', '')
|
||||
|
||||
def get_nightly(self, obj):
|
||||
return obj.version.endswith('-nightly')
|
||||
|
||||
|
||||
class ScreenshotSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
@ -90,3 +99,4 @@ class AppReleaseDownloadSerializer(serializers.Serializer):
|
|||
download = serializers.URLField(validators=[HttpsUrlValidator()])
|
||||
checksum = serializers.CharField(max_length=64, min_length=64,
|
||||
required=False)
|
||||
nightly = serializers.BooleanField(required=False, default=False)
|
||||
|
|
|
@ -96,6 +96,9 @@ class AppReleases(DestroyAPIView):
|
|||
provider = container.resolve(AppReleaseProvider)
|
||||
info = provider.get_release_info(url)
|
||||
app_id = info['app']['id']
|
||||
|
||||
if serializer.validated_data['nightly']:
|
||||
info['app']['release']['version'] += '-nightly'
|
||||
version = info['app']['release']['version']
|
||||
|
||||
if 'checksum' in serializer.validated_data:
|
||||
|
|
Загрузка…
Ссылка в новой задаче