Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/BesLogic/releaf-canopeum in…
Browse files Browse the repository at this point in the history
…to fix-capitalization-across-website
  • Loading branch information
Samuel-Therrien-Beslogic committed Nov 26, 2024
2 parents 87a9ab5 + b25fc93 commit 0acfea4
Show file tree
Hide file tree
Showing 48 changed files with 7,146 additions and 7,164 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!--
Thank you for your contribution to Beslogic's <project_name> repo.
Thank you for your contribution to Beslogic's Releaf / Canopeum repo.
Before submitting this PR, please make sure:
-->

- [ ] The project passes automated tests (build, linting, etc.).
- [ ] The project passes automated tests locally (build, linting, etc.).
- [ ] You updated the project's documentation with new changes.
- [ ] You've [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) any issue this PR closes
- [ ] You reviewed your own PR and made sure there's no test/debug code or any obvious mistakes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ def create_posts_for_site(site):
num_posts = random.randint(4, 8)
for _ in range(num_posts):
# Generate a random share_count between 0 and 10
share_count = random.randint(0, 10)
# share_count = random.randint(0, 10)

# Create a post for the site
post = Post.objects.create(
site=site,
body=f"{site.name} has planted {random.randint(100, 1000)} new trees today. "
+ "Let's continue to grow our forest!",
share_count=share_count,
# share_count=share_count,
)
# Change created_at date since it is auto-generated on create
# Generate a random created_at time within the last 2 months
Expand Down Expand Up @@ -536,7 +536,7 @@ def create_sites(self):
site=site1,
body="The season is officially started; "
+ "new plants are starting to grow and our volunteers are very dedicated!",
share_count=5,
# share_count=5,
)
post.media.add(*Asset.objects.filter(asset__contains="canopeum_post_img"))
create_posts_for_site(site1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.1 on 2024-11-26 18:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("canopeum_backend", "0001_initial"),
]

operations = [
migrations.RemoveField(
model_name="post",
name="share_count",
),
]
3 changes: 2 additions & 1 deletion canopeum_backend/canopeum_backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ def delete(self, using=None, keep_parents=False):
class Post(models.Model):
site = models.ForeignKey(Site, models.CASCADE, blank=False, null=False)
body = models.TextField(blank=False, null=False)
share_count = models.IntegerField(default=0)
# Feature currently unused, maybe eventually we'll want to track social media shares
# share_count = models.IntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True, blank=False, null=False)
# TODO(NicolasDontigny): Add created by user?
# created_by = models.ForeignKey(User, models.DO_NOTHING, blank=True, null=True)
Expand Down
2 changes: 1 addition & 1 deletion canopeum_backend/canopeum_backend/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class Meta:
"created_at",
"body",
"like_count",
"share_count",
# "share_count",
"comment_count",
"has_liked",
"media",
Expand Down
6 changes: 5 additions & 1 deletion canopeum_backend/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ def test_no_pending_migrations(self):
stderr=StringIO(),
)
except SystemExit:
raise AssertionError("Pending migrations:\n" + out.getvalue()) from None
raise AssertionError(
"Pending migrations:\n"
+ out.getvalue()
+ "\nPlease run `uv run manage.py makemigrations`"
) from None
5 changes: 2 additions & 3 deletions canopeum_frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
projectService: {
allowDefaultProject: ['*/*/*.js', '.eslintrc.cjs'],
allowDefaultProject: ['*/*/*.js', '.eslintrc.cjs', 'apiSchemaGenerator.js'],
},
// Still needed for plugins that haven't updated to typescript-eslint@8 yet
// Namely: eslint-plugin-sonarjs
Expand Down Expand Up @@ -49,13 +49,12 @@ module.exports = {
['^'],
// Relative imports.
// Anything that starts with a dot or src/
// KEEP IN SYNC WITH canopeum_frontend/tsconfig.json AND canopeum_frontend/vite.config.ts
[
// KEEP IN SYNC WITH canopeum_frontend/tsconfig.json & canopeum_frontend/vite.config.ts
'^(\\.'
+ '|src/'
+ '|@assets'
+ '|@components'
+ '|@config'
+ '|@constants'
+ '|@hooks'
+ '|@models'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as url from 'node:url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const schemaUrl = 'http://127.0.0.1:8000/api/schema/'
const outputPath = path.join(__dirname, 'openapi.yaml')
const nswagPath = path.join(__dirname, '../../..', 'docs/canopeum.nswag')
const nswagPath = path.join(__dirname, '..', 'docs', 'canopeum.nswag')

const response = await fetch(schemaUrl)
if (!response.ok) {
Expand Down
34 changes: 4 additions & 30 deletions canopeum_frontend/package-lock.json

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

5 changes: 2 additions & 3 deletions canopeum_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "cd .. && dprint check && cd canopeum_frontend && npm run eslint",
"lint:fix": "npm run eslint -- --fix && cd .. && dprint fmt",
"preview": "vite preview",
"generate-api-client": "node ./src/config/apiSchemaGenerator.js"
"generate-api-client": "node ./apiSchemaGenerator.js"
},
"// @mui/x-charts": "https://github.com/mui/mui-x/pull/14392/files#r1764019386",
"dependencies": {
Expand Down Expand Up @@ -47,13 +47,12 @@
"@types/react-transition-group": "^4.4.10",
"@vitejs/plugin-react": "^4.2.1",
"dprint": "^0.47.2",
"eslint-config-beslogic": "^3.1.1",
"eslint-config-beslogic": "^3.1.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-prefer-function-component": "^3.3.0",
"eslint-plugin-react-refresh": "^0.4.5",
"readonly-types": "^4.5.0",
"sass": "1.77.6",
"typescript": "~5.5.4",
"vite": "^5.4.6"
Expand Down
5 changes: 3 additions & 2 deletions canopeum_frontend/src/assets/styles/GlobalStyles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ body {
background-image: url('@assets/images/TreeBackground.png');
}

.text-small {
font-size: 90%;
// Named after https://getbootstrap.com/docs/5.2/utilities/text/#font-size
.fs-small {
font-size: 0.875rem;
}

.text-ellipsis {
Expand Down
16 changes: 16 additions & 0 deletions canopeum_frontend/src/assets/styles/muiCustomTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ const muiCustomTheme = createTheme({
paper: variables.cardBackground,
},
},
components: {
MuiDialogActions: {
styleOverrides: {
spacing: {
justifyContent: 'space-around',
},
},
},
MuiDialogTitle: {
styleOverrides: {
root: {
textAlign: 'center',
},
},
},
},
})

export default muiCustomTheme
2 changes: 1 addition & 1 deletion canopeum_frontend/src/components/CreatePostWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CreatePostWidget = ({ siteId, addNewPost }: Props) => {

return (
<div className='card'>
<div className='card-body rounded-2 d-flex flex-column gap-2'>
<div className='card-body d-flex flex-column gap-2'>
<div className='d-flex justify-content-between'>
<h2>{translate('social.posts.new-post')}</h2>

Expand Down
2 changes: 1 addition & 1 deletion canopeum_frontend/src/components/IconBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const IconBadge = (props: Props) => {
return (
<div
className={`${bgColor} text-center rounded-circle`}
style={{ height: '2em', width: '2em' }}
style={{ height: '2em', width: '2em', minWidth: '2em' }}
>
<span
className='material-symbols-outlined text-light align-middle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ const AnalyticsSiteHeader = ({ siteSummary }: Props) => {
</div>
</div>

<div
className='row justify-content-between mt-4 row-gap-3'
style={{ maxWidth: '880px' }}
>
<div className='row mt-4 row-gap-3'>
<SiteCountBadge
count={siteSummary.plantCount}
icon='sitePlantedIcon'
Expand All @@ -87,7 +84,7 @@ const AnalyticsSiteHeader = ({ siteSummary }: Props) => {

<div
className='d-flex align-items-center fw-bold overflow-x-auto pb-2 mt-4'
style={{ maxWidth: '800px' }}
style={{ maxWidth: '800px' }} // TODO: Magic number

Check warning on line 87 in canopeum_frontend/src/components/analytics/AnalyticsSiteHeader.tsx

View workflow job for this annotation

GitHub Actions / Lint-Autofixes

Unexpected 'TODO' comment: 'TODO: Magic number'
>
<span className='material-symbols-outlined'>group</span>
<span className='ms-1 me-2'>{translate('analyticsSite.sponsors')}:</span>
Expand Down
5 changes: 1 addition & 4 deletions canopeum_frontend/src/components/analytics/BatchActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ const BatchActions = ({ onEdit, onDelete, batchDetail }: Props) => {
className='bg-lightgreen text-center rounded-circle unstyled-button'
type='button'
>
<span
className='material-symbols-outlined text-primary align-middle'
style={{ fontSize: 24 }}
>
<span className='material-symbols-outlined text-primary align-middle'>
more_horiz
</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion canopeum_frontend/src/components/analytics/BatchTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const BatchTable = (props: Props) => {
scope='col'
style={{ width: '17.5rem' }}
>
<div className='d-flex justify-content-between align-items-center card-title'>
<div className='d-flex justify-content-between align-items-center'>
{batch.name}

<BatchActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const OptionQuantitySelector = <TValue extends OptionQuantityValueType>(
<ul className='list-group list-group-flush overflow-hidden mt-1'>
{selected.map((optionQuantity, index) => (
<li
className='list-group-item row d-flex justify-content-between'
className='list-group-item row d-flex align-items-center justify-content-between'
key={`selected-specie-${optionQuantity.option.value}`}
>
<div className='col-6'>{optionQuantity.option.displayText}</div>
Expand Down
15 changes: 9 additions & 6 deletions canopeum_frontend/src/components/analytics/SiteSummaryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ const SiteSummaryCard = ({ site, admins, onSiteChange, onSiteEdit }: Props) => {
className='col-12 col-md-6 col-xl-4 col-xxl-3'
key={site.name}
>
<div className='card h-100 w-100 py-3'>
<div className='card h-100 w-100'>
<div className='card-body d-flex flex-column h-100'>
<div className='d-flex justify-content-between align-items-center card-title'>
<Link className='nav-link flex-grow-1 me-3' to={appRoutes.site(site.id)}>
<div className='d-flex gap-1 align-items-center flex-grow-1'>
<IconBadge iconKey={getSiteTypeIconKey(site.siteType.id)} />
<h5 className='mb-0 text-ellipsis'>{site.name}</h5>
</div>
<Link
className='nav-link me-2 d-flex gap-1 align-items-center'
// idk why just 100% still goes over the card length, so adjust for icon size ?
style={{ width: 'calc(100% - 2em)' }}
to={appRoutes.site(site.id)}
>
<IconBadge iconKey={getSiteTypeIconKey(site.siteType.id)} />
<h5 className='mb-0 text-ellipsis'>{site.name}</h5>
</Link>

{currentUser?.role === 'MegaAdmin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,9 @@ const CreateBatchModal = ({ open, site, handleClose }: Props) => {

return (
<Dialog fullWidth maxWidth='sm' onClose={handleCancel} open={open}>
<DialogTitle>
<div className='fs-5 m-auto text-center'>
{t('analyticsSite.batch-modal.create-title')}
</div>
</DialogTitle>
<DialogTitle>{t('analyticsSite.batch-modal.create-title')}</DialogTitle>

<DialogContent className='pb-5'>
<DialogContent>
<BatchForm handleBatchChange={handleBatchChange} />
</DialogContent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ const BatchModal = ({ batchToEdit, handleClose }: Props) => {

return (
<Dialog fullWidth maxWidth='sm' onClose={onCancel} open={!!batchToEdit}>
<DialogTitle>
<div className='fs-5 m-auto text-center'>
{t('analyticsSite.batch-modal.edit-title')}
</div>
</DialogTitle>
<DialogTitle>{t('analyticsSite.batch-modal.edit-title')}</DialogTitle>

<DialogContent className='pb-5'>
<DialogContent>
<BatchForm
handleBatchChange={handleBatchChange}
initialBatch={batchToEdit}
Expand Down
Loading

0 comments on commit 0acfea4

Please sign in to comment.