Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #85 from Fotogjengen/update@angular-routing
Browse files Browse the repository at this point in the history
Update@angular routing
  • Loading branch information
sjsivert authored Apr 7, 2019
2 parents b331e8d + e35298d commit 53b4843
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 54 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=


Empty file modified docker-compose.override.yml
100755 → 100644
Empty file.
17 changes: 0 additions & 17 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# Stage 1
FROM node:9-alpine as build-deps
RUN npm i @angular/[email protected] [email protected] -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
Empty file modified nginx/default.conf
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions postgres/scripts/restore_old_db_from_dump.sh
Original file line number Diff line number Diff line change
@@ -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
46 changes: 34 additions & 12 deletions src/angular_frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/angular_frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const routes: Routes = [
{
path: '',
redirectTo: '/forside',
pathMatch: 'full'
pathMatch: 'full',
},
{
path: 'forside',
Expand Down Expand Up @@ -175,7 +175,9 @@ const routes: Routes = [
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
imports: [RouterModule.forRoot(routes, {
useHash: true
})],
exports: [RouterModule]
})
export class AppRoutingModule { }
Empty file modified src/angular_frontend/src/app/services/rss.service.spec.ts
100755 → 100644
Empty file.
Empty file modified src/angular_frontend/src/app/services/rss.service.ts
100755 → 100644
Empty file.
57 changes: 37 additions & 20 deletions src/django_backend/convert_old_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand 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()

Expand 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()

Expand 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()

Expand 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()

Expand 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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand All @@ -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


Expand Down
Loading

0 comments on commit 53b4843

Please sign in to comment.