diff --git a/.travis.yml b/.travis.yml old mode 100755 new mode 100644 index a448a81..f4fd599 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ services: cache: directories: - src/angular_frontend/node_modules -install: -- npm install -g yarn addons: ssh_known_hosts: - 146.185.181.250 @@ -57,6 +55,6 @@ deploy: branch: master notifications: slack: - secure: YlcczsJzqvtxcLnrELRX1RLbMjKkxYrhf4y7yBPqwzXaWzzmUML8K1RWqCA94tD66IRCK5GOZoE4qZb7RMDt7o1fN9Qn19wbbEbJkGmookFF8eindslBxyxKW9195Mxk0ZGpEuItfwoE3Le3KPg/kXAODoQPnYoHMi89tCOnzqzryKhmyhq+6qJ8tnIIEuNoQ3kHwoudWmRHAVB3CC9vJW3RRrTSCtis+t9lcgqmt2mouAFCXEwjFxzD+KwUOPqqdjMeZZh4V8g7Z4piS5WpyLqvNmJrKelURxI3sW/CBUFp0WLpjvdOsaYsIYntlsqbCAe/NoTFO0MDK4lMfJRv/XB66+Ou8WltJQC6ygj4ulrDeJTBAxMmy28zojvoZp7BBKpYjQNiZ3G9rL6FkOuJhM+C9jbzrony+DDNcOJvkJogs4X6rJyPO2ekNWQWoEagwOkCn0LGO1b7LkEi15DgeHPae9nKtldCi0jsWdcb3Y6yP7Ot0HTyT5z4mPb8jEThHHjuMnFVeaobwLiNcamK00Y0AuQXgolvEWOyIfjGP1qPKI7W9oJrtQ/EyumGvINGLs4OMjAVX4uCxmg+9iOvDXkP5h2AmKc0sjbND7uznvktVKay88oOiFUW/XXXEOYkUw6HfxNzVkZKlqzf+6HxamIi5QgZdS5UqXZvmSmeLv8= + secure: YlcczsJzqvtxcLnrELRX1RLbMjKkxYrhf4y7yBPqwzXaWzzmUML8K1RWqCA94tD66IRCK5GOZoE4qZb7RMDt7o1fN9Qn19wbbEbJkGmookFF8eindslBxyxKW9195Mxk0ZGpEuItfwoE3Le3KPg/kXAODoQPnYoHMi89tCOnzqzryKhmyhq+6qJ8tnIIEuNoQ3kHwoudWmRHAVB3CC9vJW3RRrTSCtis+t9lcgqmt2mouAFCXEwjFxzD+KwUOPqqdjMeZZh4V8g7Z4piS5WpyLqvNmJrKelURxI3sW/CBUFp0WLpjvdOsaYsIYntlsqbCAe/NoTFO0MDK4lMfJRv/XB66+Ou8WltJQC6ygj4ulrDeJTBAxMmy28zojvoZp7BBKpYjQNiZ3G9rL6FkOuJhM+C9jbzrony+DDNcOJvkJogs4X6rJyPO2ekNWQWoEagwOkCn0LGO1b7LkEi15DgeHPae9nKtldCi0jsWdcb3Y6yP7Ot0HTyT5z4mPb8jEThHHjuMnFVeaobwLiNcamK00Y0AuQXgolvEWOyIfjGP1qPKI7W9oJrtQ/EyumGvINGLs4OMjAVX4uCxmg+9iOvDXkP5h2AmKc0sjbND7uznvktVKay88oOiFUW/XXXEOYkUw6HfxNzVkZKlqzf+6HxamIi5QgZdS5UqXZvmSmeLv8= diff --git a/docker-compose.override.yml b/docker-compose.override.yml old mode 100755 new mode 100644 diff --git a/nginx/Dockerfile b/nginx/Dockerfile index c7bf5bb..0580b2a 100755 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,21 +1,4 @@ -# Stage 1 -FROM node:9-alpine as build-deps -RUN npm i @angular/cli@1.6.3 node-sass@4.9.3 -g --unsafe-perm - -WORKDIR /src - -# Copy files defining dependency first -COPY src/angular_frontend/package.json . -COPY src/angular_frontend/package-lock.json . -RUN npm i && npm rebuild node-sass - -# Then copy over the rest of directory and build -COPY src/angular_frontend/ . -RUN ng build - -# Stage 2 FROM nginx:1.15.0 COPY nginx/nginx.conf /etc/nginx/nginx.conf COPY nginx/default.conf /etc/nginx/conf.d/default.conf -COPY --from=build-deps /src/dist /static/angular/dist diff --git a/nginx/default.conf b/nginx/default.conf old mode 100755 new mode 100644 diff --git a/postgres/scripts/restore_old_db_from_dump.sh b/postgres/scripts/restore_old_db_from_dump.sh index 87a966e..0a58eb7 100755 --- a/postgres/scripts/restore_old_db_from_dump.sh +++ b/postgres/scripts/restore_old_db_from_dump.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash dropdb --if-exists 'old_fg' createdb -U postgres -T template0 old_fg psql -U postgres -d old_fg -f /data/dump.sql diff --git a/src/angular_frontend/package-lock.json b/src/angular_frontend/package-lock.json index 8aaaf68..78c8e4a 100755 --- a/src/angular_frontend/package-lock.json +++ b/src/angular_frontend/package-lock.json @@ -1638,6 +1638,7 @@ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -1649,6 +1650,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -5005,7 +5007,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5029,13 +5032,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5052,19 +5057,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5195,7 +5203,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5209,6 +5218,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5225,6 +5235,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5233,13 +5244,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5260,6 +5273,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5348,7 +5362,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5362,6 +5377,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5457,7 +5473,8 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5499,6 +5516,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5520,6 +5538,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5568,13 +5587,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, @@ -7652,7 +7673,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "dev": true, + "optional": true }, "loose-envify": { "version": "1.4.0", diff --git a/src/angular_frontend/src/app/app-routing.module.ts b/src/angular_frontend/src/app/app-routing.module.ts index d74e22e..96ffb9d 100755 --- a/src/angular_frontend/src/app/app-routing.module.ts +++ b/src/angular_frontend/src/app/app-routing.module.ts @@ -40,7 +40,7 @@ const routes: Routes = [ { path: '', redirectTo: '/forside', - pathMatch: 'full' + pathMatch: 'full', }, { path: 'forside', @@ -175,7 +175,9 @@ const routes: Routes = [ ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [RouterModule.forRoot(routes, { + useHash: true + })], exports: [RouterModule] }) export class AppRoutingModule { } diff --git a/src/angular_frontend/src/app/services/rss.service.spec.ts b/src/angular_frontend/src/app/services/rss.service.spec.ts old mode 100755 new mode 100644 diff --git a/src/angular_frontend/src/app/services/rss.service.ts b/src/angular_frontend/src/app/services/rss.service.ts old mode 100755 new mode 100644 diff --git a/src/django_backend/convert_old_db.py b/src/django_backend/convert_old_db.py index a7495b9..a2f766d 100755 --- a/src/django_backend/convert_old_db.py +++ b/src/django_backend/convert_old_db.py @@ -3,9 +3,11 @@ import sys import json import logging + sys.path.append('/django') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fg.settings") import django + django.setup() from django.core.exceptions import ObjectDoesNotExist @@ -18,7 +20,7 @@ logging.basicConfig(level=logging.INFO) -def convert_SecurityLevel(): +def convert_security_level(): logging.info("Converting security_levels") old_security_levels = old_models.FgAuthSecuritylevel.objects.using( 'old_db').all() @@ -31,7 +33,7 @@ def convert_SecurityLevel(): models.SecurityLevel.objects.bulk_create(obj_list) -def convert_Tag(): +def convert_tag(): logging.info("Converting tags") old_tags = old_models.ArchiveTag.objects.using('old_db').all() @@ -43,7 +45,7 @@ def convert_Tag(): models.Tag.objects.bulk_create(obj_list) -def convert_Category(): +def convert_category(): logging.info("Converting categories") old_categories = old_models.ArchiveCategory.objects.using('old_db').all() @@ -55,7 +57,7 @@ def convert_Category(): models.Category.objects.bulk_create(obj_list) -def convert_Album(): +def convert_album(): logging.info("Converting albums") old_albums = old_models.ArchiveAlbum.objects.using('old_db').all() @@ -79,7 +81,7 @@ def convert_Album(): models.Album.objects.bulk_create(obj_list) -def convert_Media(): +def convert_media(): logging.info("Converting mediums") old_mediums = old_models.ArchiveMedia.objects.using('old_db').all() @@ -91,7 +93,7 @@ def convert_Media(): models.Media.objects.bulk_create(obj_list) -def convert_Place(): +def convert_place(): logging.info("Converting places") old_places = old_models.ArchivePlace.objects.using('old_db').all() @@ -124,7 +126,21 @@ def get_latest_image_number_and_page_number(album_pk): } -def convert_Photo(): +def date_to_week(date): + # %V - The ISO 8601 week number of the current year (01 to 53), + # where week 1 is the first week that has at least 4 days in the current year, + # and with Monday as the first day of the week. + week = date.strftime("V") + month = date.month + if week == 52 or week == 53: + if month == 12: + return 52 # Week should be 52 if it is december + if month == 1: + return 1 # Week should be 1 if taken in january before transition to week 1 + return week # Else return week number we got earlier + + +def convert_photo(): logging.info("Converting Photos") old_photo_set = old_models.ArchiveImagemodel.objects.using('old_db').all() @@ -158,6 +174,7 @@ def convert_Photo(): page=item.page, image_number=item.image_number, date_taken=item.date, + week_taken=date_to_week(item.date), security_level_id=item.security_level.pk, category_id=item.category.pk, @@ -196,7 +213,7 @@ def convert_Photo(): logging.info(resp) -def attach_Tags_to_photos(): +def attach_tags_to_photos(): logging.info("attaching tags to photos") old_tag2photo_set = old_models.ArchiveImagemodelTag.objects.using( 'old_db').order_by('imagemodel')[::1] @@ -215,18 +232,18 @@ def attach_Tags_to_photos(): def convert(): - User.objects.create_superuser( - username='fg', email='', password='qwer1234') - - convert_SecurityLevel() - convert_Tag() - convert_Category() - convert_Album() - convert_Media() - convert_Place() - convert_Photo() - - attach_Tags_to_photos() + # User.objects.create_superuser( + # username='fg', email='', password='qwer1234') + + convert_security_level() + convert_tag() + convert_category() + convert_album() + convert_media() + convert_place() + convert_photo() + + attach_tags_to_photos() # TODO move users and user_photo_downloaded in as well diff --git a/src/django_backend/date_to_week.py b/src/django_backend/date_to_week.py new file mode 100644 index 0000000..a784914 --- /dev/null +++ b/src/django_backend/date_to_week.py @@ -0,0 +1,36 @@ +import datetime +import calendar + + +# I am assuming that the first week of a month starts with the first monday of a month... +# I *think* my logic is OK - if Monday (0) is the start of the week, then +# any dayof the month minus its own day of week (0,1,2...) must be positive +# if that day is on or after the first monday of the month + + +def week_of_month(tgtdate): + days_this_month = calendar.mdays[tgtdate.month] + for i in range(1, days_this_month): + d = datetime.date(tgtdate.year, tgtdate.month, i) + if d.day - d.weekday() > 0: + startdate = d + break + # now we canuse the modulo 7 appraoch + return (tgtdate - startdate).days // 7 + 1 + + +tgtdates = [datetime.date(2016, 1, 29), + datetime.date(2016, 1, 1) + ] + + +def date_to_month(date): + print(date.strftime("%V")) + print(date.month) + + +for tgt in tgtdates: + # print(tgt), + # print("is in week %s" % week_of_month(tgt)) + # print(calendar.month(tgt.year, tgt.month)) + date_to_month(tgt)